配置docker官方源并用yum安装docker

一、docker的官方安装文档

https://docs.docker.com/engine/installation/linux/centos/

由docker给的文档可以看出它也只是去配置了一个docker的yum源、然后就通过这个源来安装docker了;在这个文档下我们采用手工配置

的方式

二、配置一个docker用的源

  1、为docker 增加一个新的yum配置文件;touch /etc/yum.repos.d/docker.repo

touch /etc/yum.repos.d/docker.repo

  2、docker.repo的内容如下

[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=0 #我把这里设置成了0、说明我信任了这个源,不对它的rpm进行检察
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://download.docker.com/linux/centos/7/source/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge]
name=Docker CE Edge - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge-debuginfo]
name=Docker CE Edge - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-edge-source]
name=Docker CE Edge - Sources
baseurl=https://download.docker.com/linux/centos/7/source/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://download.docker.com/linux/centos/7/source/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

三、安装docker:

sudo yum install docker-ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:17.03.1.ce-1.el7.centos will be installed
--> Processing Dependency: docker-ce-selinux >= 17.03.1.ce-1.el7.centos for package: docker-ce-17.03.1.ce-1.el7.centos.x86_64
--> Running transaction check
---> Package docker-ce-selinux.noarch 0:17.03.1.ce-1.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================
 Package                          Arch                  Version                                Repository                       Size
=====================================================================================================================================
Installing:
 docker-ce                        x86_64                17.03.1.ce-1.el7.centos                docker-ce-stable                 19 M
Installing for dependencies:
 docker-ce-selinux                noarch                17.03.1.ce-1.el7.centos                docker-ce-stable                 28 k

Transaction Summary
=====================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 19 M
Installed size: 19 M
Is this ok [y/d/N]: y

四、直接下载rpm包的方式来安装

  1、我在安装docker的时候发现下载的速度只有3kB/s 然而文件大小有19M;就在我感觉安装无望的时候、我机智的想到了自己直接把rpm下载下来

  看了下docker.repo 、发现centos7的源地址是 https://download.docker.com/linux/centos/7/$basearch/stable 所以我只要去

https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

  用迅雷(我是会员有加速)把rpm包下载下来就行了

  下载如下文件:

docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm

五、安装docker:

ll
total 19096
-rwxrwxrwx 1 jianglexing jianglexing 19521288 May 30 20:05 docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
-rw-r--r-- 1 jianglexing jianglexing    29108 May 30 20:15 docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm
[[email protected] docker]# yum localinstall *
Loaded plugins: fastestmirror, langpacks
Examining docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm: docker-ce-17.03.0.ce-1.el7.centos.x86_64
Marking docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm to be installed
Examining docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm: docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch
Marking docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:17.03.0.ce-1.el7.centos will be installed
---> Package docker-ce-selinux.noarch 0:17.03.0.ce-1.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================
 Package                 Arch         Version                          Repository                                               Size
=====================================================================================================================================
Installing:
 docker-ce               x86_64       17.03.0.ce-1.el7.centos          /docker-ce-17.03.0.ce-1.el7.centos.x86_64                65 M
 docker-ce-selinux       noarch       17.03.0.ce-1.el7.centos          /docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch        43 k

Transaction Summary
=====================================================================================================================================
Install  2 Packages

Total size: 65 M
Installed size: 65 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch                                                                  1/2
setsebool:  SELinux is disabled.
libsemanage.semanage_direct_install_info: Overriding docker module at lower priority 100 with module at priority 400.
  Installing : docker-ce-17.03.0.ce-1.el7.centos.x86_64                                                                          2/2
  Verifying  : docker-ce-17.03.0.ce-1.el7.centos.x86_64                                                                          1/2
  Verifying  : docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch                                                                  2/2 

Installed:
  docker-ce.x86_64 0:17.03.0.ce-1.el7.centos                    docker-ce-selinux.noarch 0:17.03.0.ce-1.el7.centos                   

Complete!

六、启动docker:

[[email protected] docker]# systemctl start docker
[[email protected] docker]# ps -ef | grep docker
root       4458      1  1 20:22 ?        00:00:00 /usr/bin/dockerd
root       4465   4458  0 20:22 ?        00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --shim docker-containerd-shim --runtime docker-runc
root       4589   4333  0 20:22 pts/1    00:00:00 grep --color=auto docker

七、测试docker是否能成功运行

[[email protected] docker]# docker run hello-world
Unable to find image ‘hello-world:latest‘ locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

如下是第一次运行hello-world 这个docker-image 由于它还不存在于本地、所以要下载它、这可能要用一点时间!

----

时间: 2024-10-17 14:57:28

配置docker官方源并用yum安装docker的相关文章

redhat 如何配置使用centos源进行yum安装以及升级

如何设置redhat使用centos源,可以借助yum工具进行安装各种所需的包,以及进行系统升级.这里设置的是redhat6.0 对应的centos版本也是6.0 内核版本是2.6.32-71.el6.x86_64这里base源设置的是163的镜像站而epel扩展源使用的则是sohu镜像站 1.首先确认yum相关的rpm包,并卸载rpm -aq|grep yum|xargs rpm -e --nodeps2.下载163相关rpm 包 wget http://mirrors.163.com/cen

yum 安装docker后 无法启动

一,yum安装docker yum -y install docker 启动docker service docker start 报错: journalctl -xe Error starting daemon: SELinux is not supported with the overlay2 graph driver on this kernel. Failed to start Docker Application Container Engine. 可以看出错误信息 Error st

Docker官方Centos镜像下安装Elasticsearch【详细步骤】

运行docker镜像[官方centos] 启动容器 docker run -it -d -p 9000-9900:9000-9900 --name cenosElasticsearch centos docker run -it -d -p 9200:9200 -p 9300:9300 --name cenosElasticsearch3 e11524101e04 查看容器并进入 docker ps docker attach e584c6fb2eff 这里启动容器选择了一段ip和主机ip映射「

CentOS7.0 yum安装 docker

一.安装docker 1.Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker . root 用户登录操作! 通过 uname -r 命令查看你当前的内核版本 # uname -r 2.使用 root 权限登录 Centos.确保 yum 包更新到最新. # yum update 3.卸载旧版本(如果安装过旧版本的话) # yum remove docker docker-common docker-selinu

基于源码包安装docker

下载docker-1.12.6.tgz bash tar -zxvf docker-1.12.6.tgz cp docker/* /usr/bin/ dockerd -g /home/docker & 配置docker镜像源 cd /etc/docker vi /dameon.json { "registry-mirrors": ["https://w8qazxxa.mirror.aliyuncs.com"] } 原文地址:https://www.cnblo

Docker系列:入门篇-安装docker

Docker 提供了两个版本:社区版 (CE) 和企业版 (EE). Docker 社区版 (CE) 是开发人员和小型团队开始使用 Docker 并尝试使用基于容器的应用的理想之选,所以这里我们来说一下Docker社区版的安装 操作系统要求 64位 CentOS 这里只说明centos上的安装方法 卸载旧版本 Docker 的早期版本称为 docker 或 docker-engine.如果安装了这些版本,请卸载它们及关联的依赖资源. $ sudo yum remove docker docker

Linux Apache php MySQL 安装配置(Centos 6.4 yum安装)

一.yum准备 1.Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器. 基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载.安装. 2.在安装软件时报’Couldn't resolve host 'mirrorlist.centos.org‘ 解决:打开文件/etc/resolv.conf在其中添加: (添

搭建本地 yum 源 离线安装 Docker 1.12.6

使用 yum 安装 docker ,需要访问互联网.有时内网环境的机器也需要安装docker.直接使用rpm 包安装需要解决各种各样的依赖,搭建本地yum 源是一个很好解决问题的方法. centos yum 命令 提供了一种只下载不安装的命令 . yum  --downloadonly   ,  --downloaddir=DLDIR  ,下面是构建的详细步骤 环境准备 选择一台可以连接外网的服务器.保证可以相应的软件安装包 下载docker 软件 mkdir -p /opt/docker/do

centos7安装docker并配置php运行环境

原文:centos7安装docker并配置php运行环境 一.安装docker 首先我们先来了解一下什么是docker. docker是一个虚拟化的技术,基于 Linux 内核,是将进程进行封装隔离,由于隔离的进程独立于宿主机和其它的隔离的进程,因此也可以称为容器.很多人把docker理解为虚拟机,其实不是的,因为它不需要进行硬件虚拟以及运行完整操作系统等额外开销的,docker的出现也是为了解决在各种复杂的环境下不需要做任何的修改还可以保证程序正常稳定的运行,也就是环境一致性的问题,当然还有k