docker 安装azkaban_Docker 系列01: Centos7.3 上安装docker

Docker从1.13版本之后采用时间线的方式作为版本号,分为社区版CE和企业版EE。

社区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外的收费服务,比如经过官方测试认证过的基础设施、容器、插件等。

社区版按照stable和edge两种方式发布,每个季度更新stable版本,如17.06,17.09;每个月份更新edge版本,如17.09,17.10。

一、安装docker

1、Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。

通过 uname -r命令查看你当前的内核版本

uname -r

2、使用 root 权限登录 Centos。确保 yum 包更新到最新。

yum update

3、卸载旧版本(如果安装过旧版本的话)

yum -y remove docker docker-common docker-selinux docker-engine

4、安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的

yum install -y yum-utils device-mapper-persistent-data lvm2

5、设置yum源

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo #阿里云yum源

6、可以查看所有仓库中所有docker版本,并选择特定版本安装

yum list docker-ce --showduplicates | sort -r*updates: mirrors.aliyun.com

Loading mirror speeds from cached hostfile

Loaded plugins: fastestmirror

Installed Packages*extras: mirrors.aliyun.com

docker-ce.x86_64 3:19.03.9-3.el7 docker-ce-stable

docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable

docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stable

docker-ce.x86_64 3:19.03.6-3.el7 docker-ce-stable

docker-ce.x86_64 3:19.03.5-3.el7 docker-ce-stable

docker-ce.x86_64 3:19.03.4-3.el7 docker-ce-stable

docker-ce.x86_64 3:19.03.3-3.el7 docker-ce-stable

docker-ce.x86_64 3:19.03.2-3.el7 docker-ce-stable

docker-ce.x86_64 3:19.03.1-3.el7 docker-ce-stable

docker-ce.x86_64 3:19.03.12-3.el7 docker-ce-stable

docker-ce.x86_64 3:19.03.11-3.el7 docker-ce-stable

docker-ce.x86_64 3:19.03.10-3.el7 docker-ce-stable

docker-ce.x86_64 3:19.03.10-3.el7 @docker-ce-stable

docker-ce.x86_64 3:19.03.0-3.el7 docker-ce-stable

docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable

docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable

docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable

docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable

docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable

docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable

docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable

docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable

docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable

docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable

docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable

docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable

docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable

docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable

docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable

docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable

docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable*base: mirrors.aliyun.com

Available Packages

7、安装docker(含特定版本)

#由于repo中默认只开启stable仓库,故这里安装的是最新稳定版19.03.12#toinstallspecified version of docker,

#use:yum install -y #toinstalllatest version, use command like:

#yum install -y docker-ce , because the latest version of docker is 19.03.12, so this command is equivalent with command:

#yum install -y docker-ce-19.03.12-3.el7yum install -y docker-ce-19.03.10-3.el7

8、启动并加入开机启动

systemctl start docker

systemctl enable docker

9、验证安装是否成功(有client和service两部分表示docker安装启动都成功了)

docker version

二、问题

1、因为之前已经安装过旧版本的docker,在安装的时候报错如下:

Transaction check error:file /usr/bin/docker from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64file /usr/bin/docker-containerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64file /usr/bin/docker-containerd-shim from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64file /usr/bin/dockerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64

2、卸载旧版本的包

yum erase docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64

l另外一种删除docker的方法如下:

yum remove docker docker-common docker-selinux docker-engine -y/etc/systemd -name '*docker*' -exec rm -f {} ;find /etc/systemd -name '*docker*' -exec rm -f {} \;find /lib/systemd -name '*docker*' -exec rm -f {} \;

3、再次安装docker

yum install -y docker-ce

4、在step 2.7 docker-ce安装过程中,可能会出现由于无法访问repo源,或网速太慢无法安装完成的问题

错误信息类似:

Dependencies Resolved==========================================================================================================================================================================================Package Arch Version Repository Size==========================================================================================================================================================================================Installing:

docker-ce x86_64 18.06.3.ce-3.el7 docker-ce-stable 41M

Installingfordependencies:

libtool-ltdl x86_64 2.4.2-22.el7_3 base 49k

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

Total download size:41M

Installed size:168M

Is this ok [y/d/N]: y

Downloading packages:

(1/2): libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm | 49 kB 00:00:05docker-ce-18.06.3.ce-3.el7.x86 FAILED 0% [ ] 6.7 B/s | 78 kB 1759:58:04ETA

https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-18.06.3.ce-3.el7.x86_64.rpm: [Errno 12] Timeout onhttps://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-18.06.3.ce-3.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')

Trying other mirror.

docker-ce-18.06.3.ce-3.el7.x86 FAILED 0% [ ] 1.8 B/s | 112 kB 6558:40:59ETA

https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-18.06.3.ce-3.el7.x86_64.rpm: [Errno 12] Timeout onhttps://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-18.06.3.ce-3.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')

Trying other mirror.

docker-ce-18.06.3.ce-3.el7.x86 FAILED 0% [ ] 11 B/s | 226 kB 1084:46:05ETA

https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-18.06.3.ce-3.el7.x86_64.rpm: [Errno 12] Timeout onhttps://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-18.06.3.ce-3.el7.x86_64.rpm: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')

Trying other mirror.

(2/2): docker-ce-18.06.3.ce-3.el7.x86_64.rpm 0% [ ] 245 B

解决办法:

用其他方式把rpm包下载下来,然后使用下面命令进行安装

yum install -y *.rpm

参考的下载方法1:

只下载特定版本的rpm包到指定路径,但是不安装

yum install --downloadonly --downloaddir=/home/lenmom docker-ce-18.06.3.ce-3.el7yum install --downloadonly --downloaddir=/home/lenmom libtool-ltdl-2.4.2-22.el7_3yum install --downloadonly --downloaddir=/home/lenmom container-selinux-2.107-3.el7

参考下载方式2:

使用下载工具,如迅雷,下载指定的rpm包,下载地址可以在yum install 的输出中找到

三、 配置阿里云镜像加速器

针对Docker客户端版本大于1.10.0的用户,可以通过修改daemon配置文件新版的 Docker 使用 /etc/docker/daemon.json(Linux) 或者 %programdata%\docker\config\daemon.json(Windows) 来使用加速器:

1.创建文件夹(如存在无需重复创建)

mkdir -p /etc/dockervi /etc/docker/daemon.json

添加以下内容:

{"registry-mirrors":

["https://5f2jam6c.mirror.aliyuncs.com","http://hub-mirror.c.163.com"]

}

2. 重新加载配置文件

systemctl daemon-reload

3. 重启Docker

systemctl restart docker

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值