一, docker 安装条件
- 64 bit CPU
- Linux kernel 3.10+
3.Linux kernel 支持 cgroups and namespaces
CentOS 7.4 x64 为的满足条件. 实际上 CentOS 6.x 系列也能安装 docker.
二, 下载和安装 yum 源
下载 yum 文件
[root@node1 yum.repos.d]# wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
修改 yum 文件, 因为 yum 文件中的地址为 docker 官方地址, 下载比较慢
VIM 中替换网址为清华的地址:
%s@https://download.docker.com/@https://mirrors.tuna.tsinghua.edu.cn/docker-ce/@
yum repolist 查看
[root@node1 yum.repos.d]# yum repolist
已加载插件: fastestmirror, langpacks
- base | 3.6 kB 00:00:00
- docker-ce-stable | 3.5 kB 00:00:00
- extras | 3.4 kB 00:00:00
- updates | 3.4 kB 00:00:00
- zabbix | 2.9 kB 00:00:00
- zabbix-non-supported | 951 B 00:00:00
- (1/6): base/7/x86_64/group_gz | 166 kB 00:00:01
- (2/6): updates/7/x86_64/primary_db | 1.3 MB 00:00:00
- (3/6): extras/7/x86_64/primary_db | 153 kB 00:00:01
- (4/6): base/7/x86_64/primary_db | 6.0 MB 00:00:01
- (5/6): docker-ce-stable/x86_64/primary_db | 19 kB 00:00:02
- (6/6): docker-ce-stable/x86_64/updateinfo | 55 B 00:00:03
- Loading mirror speeds from cached hostfile
- * base: mirrors.cn99.com
- * extras: mirrors.cn99.com
- * updates: mirrors.cn99.com
源标识 源名称 状态
- base/7/x86_64 CentOS-7 - Base 10,019
- docker-ce-stable/x86_64 Docker CE Stable - x86_64 25
- extras/7/x86_64 CentOS-7 - Extras 312
- updates/7/x86_64 CentOS-7 - Updates 574
- zabbix/x86_64 Zabbix Official Repository - x86_64 236
- zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x86_64 4
- repolist: 11,170
可以看到有 docker-ce 了. docker 现有两个版本, 一个是付费的商业版 (docker-ee), 一个是免费的社区版 (docker-ce)
三, 安装 docker
[root@node1 yum.repos.d]# yum install docker-ce -y
已加载插件: fastestmirror, langpacks
- Loading mirror speeds from cached hostfile
- * base: mirrors.cn99.com
- * extras: mirrors.cn99.com
- * updates: mirrors.cn99.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.3.18.09.0-3.el7 将被 安装
--> 正在处理依赖关系 container-selinux>= 2.9, 它被软件包 3:docker-ce-18.09.0-3.el7.x86_64 需要
--> 正在处理依赖关系 containerd.io, 它被软件包 3:docker-ce-18.09.0-3.el7.x86_64 需要
--> 正在处理依赖关系 docker-ce-cli, 它被软件包 3:docker-ce-18.09.0-3.el7.x86_64 需要
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.74-1.el7 将被 安装
--> 正在处理依赖关系 selinux-policy-targeted>= 3.13.1-216.el7, 它被软件包 2:container-selinux-2.74-1.el7.noarch 需要
--> 正在处理依赖关系 selinux-policy-base>= 3.13.1-216.el7, 它被软件包 2:container-selinux-2.74-1.el7.noarch 需要
--> 正在处理依赖关系 selinux-policy>= 3.13.1-216.el7, 它被软件包 2:container-selinux-2.74-1.el7.noarch 需要
---> 软件包 containerd.io.x86_64.0.1.2.0-3.el7 将被 安装
---> 软件包 docker-ce-cli.x86_64.1.18.09.0-3.el7 将被 安装
--> 正在检查事务
---> 软件包 selinux-policy.noarch.0.3.13.1-166.el7 将被 升级
---> 软件包 selinux-policy.noarch.0.3.13.1-229.el7_6.6 将被 更新
--> 正在处理依赖关系 policycoreutils>= 2.5-24, 它被软件包 selinux-policy-3.13.1-229.el7_6.6.noarch 需要
--> 正在处理依赖关系 libsemanage>= 2.5-13, 它被软件包 selinux-policy-3.13.1-229.el7_6.6.noarch 需要
---> 软件包 selinux-policy-targeted.noarch.0.3.13.1-166.el7 将被 升级
---> 软件包 selinux-policy-targeted.noarch.0.3.13.1-229.el7_6.6 将被 更新
--> 正在检查事务
---> 软件包 libsemanage.x86_64.0.2.5-8.el7 将被 升级
--> 正在处理依赖关系 libsemanage = 2.5-8.el7, 它被软件包 libsemanage-python-2.5-8.el7.x86_64 需要
---> 软件包 libsemanage.x86_64.0.2.5-14.el7 将被 更新
--> 正在处理依赖关系 libsepol>= 2.5-10, 它被软件包 libsemanage-2.5-14.el7.x86_64 需要
--> 正在处理依赖关系 libselinux>= 2.5-14, 它被软件包 libsemanage-2.5-14.el7.x86_64 需要
---> 软件包 policycoreutils.x86_64.0.2.5-17.1.el7 将被 升级
--> 正在处理依赖关系 policycoreutils = 2.5-17.1.el7, 它被软件包 policycoreutils-python-2.5-17.1.el7.x86_64 需要
---> 软件包 policycoreutils.x86_64.0.2.5-29.el7 将被 更新
--> 正在处理依赖关系 libselinux-utils>= 2.5-14, 它被软件包 policycoreutils-2.5-29.el7.x86_64 需要
--> 正在检查事务
---> 软件包 libselinux.x86_64.0.2.5-11.el7 将被 升级
--> 正在处理依赖关系 libselinux(x86-64) = 2.5-11.el7, 它被软件包 libselinux-python-2.5-11.el7.x86_64 需要
---> 软件包 libselinux.x86_64.0.2.5-14.1.el7 将被 更新
---> 软件包 libselinux-utils.x86_64.0.2.5-11.el7 将被 升级
---> 软件包 libselinux-utils.x86_64.0.2.5-14.1.el7 将被 更新
---> 软件包 libsemanage-python.x86_64.0.2.5-8.el7 将被 升级
---> 软件包 libsemanage-python.x86_64.0.2.5-14.el7 将被 更新
---> 软件包 libsepol.x86_64.0.2.5-6.el7 将被 升级
---> 软件包 libsepol.x86_64.0.2.5-10.el7 将被 更新
---> 软件包 policycoreutils-python.x86_64.0.2.5-17.1.el7 将被 升级
---> 软件包 policycoreutils-python.x86_64.0.2.5-29.el7 将被 更新
--> 正在处理依赖关系 setools-libs>= 3.3.8-4, 它被软件包 policycoreutils-python-2.5-29.el7.x86_64 需要
--> 正在检查事务
---> 软件包 libselinux-python.x86_64.0.2.5-11.el7 将被 升级
---> 软件包 libselinux-python.x86_64.0.2.5-14.1.el7 将被 更新
---> 软件包 setools-libs.x86_64.0.3.3.8-1.1.el7 将被 升级
---> 软件包 setools-libs.x86_64.0.3.3.8-4.el7 将被 更新
--> 解决依赖关系完成
依赖关系解决
==============================================================================================================================================================================================================================================================================
Package 架构 版本 源 大小
==============================================================================================================================================================================================================================================================================
正在安装:
docker-ce x86_64 3:18.09.0-3.el7 docker-ce-stable 19 M
为依赖而安装:
- container-selinux noarch 2:2.74-1.el7 extras 38 k
- containerd.io x86_64 1.2.0-3.el7 docker-ce-stable 22 M
- docker-ce-cli x86_64 1:18.09.0-3.el7 docker-ce-stable 14 M
为依赖而更新:
- libselinux x86_64 2.5-14.1.el7 base 162 k
- libselinux-python x86_64 2.5-14.1.el7 base 235 k
- libselinux-utils x86_64 2.5-14.1.el7 base 151 k
- libsemanage x86_64 2.5-14.el7 base 151 k
- libsemanage-python x86_64 2.5-14.el7 base 113 k
- libsepol x86_64 2.5-10.el7 base 297 k
- policycoreutils x86_64 2.5-29.el7 base 916 k
- policycoreutils-python x86_64 2.5-29.el7 base 456 k
- selinux-policy noarch 3.13.1-229.el7_6.6 updates 483 k
- selinux-policy-targeted noarch 3.13.1-229.el7_6.6 updates 6.9 M
- setools-libs x86_64 3.3.8-4.el7 base 620 k
事务概要
==============================================================================================================================================================================================================================================================================
安装 1 软件包 (+ 3 依赖软件包)
升级 ( 11 依赖软件包)
总下载量: 65 M
- Downloading packages:
- No Presto metadata available for base
- updates/7/x86_64/prestodelta | 169 kB 00:00:01
- (1/15): container-selinux-2.74-1.el7.noarch.rpm | 38 kB 00:00:00
- warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-18.09.0-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY================================ ] 5.6 MB/s | 33 MB 00:00:05 ETA
docker-ce-18.09.0-3.el7.x86_64.rpm 的公钥尚未安装
- (2/15): docker-ce-18.09.0-3.el7.x86_64.rpm | 19 MB 00:00:04
- (3/15): libselinux-2.5-14.1.el7.x86_64.rpm | 162 kB 00:00:00
- (4/15): libselinux-utils-2.5-14.1.el7.x86_64.rpm | 151 kB 00:00:00
- (5/15): libsemanage-2.5-14.el7.x86_64.rpm | 151 kB 00:00:00
- (6/15): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
- (7/15): libsepol-2.5-10.el7.x86_64.rpm | 297 kB 00:00:00
- (8/15): policycoreutils-2.5-29.el7.x86_64.rpm | 916 kB 00:00:00
- (9/15): libselinux-python-2.5-14.1.el7.x86_64.rpm | 235 kB 00:00:00
- (10/15): selinux-policy-3.13.1-229.el7_6.6.noarch.rpm | 483 kB 00:00:00
- (11/15): containerd.io-1.2.0-3.el7.x86_64.rpm | 22 MB 00:00:06
- (12/15): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
- (13/15): selinux-policy-targeted-3.13.1-229.el7_6.6.noarch.rpm | 6.9 MB 00:00:02
- (14/15): docker-ce-cli-18.09.0-3.el7.x86_64.rpm | 14 MB 00:00:02
- (15/15): policycoreutils-python-2.5-29.el7.x86_64.rpm | 456 kB 00:00:02
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计 8.0 MB/s | 65 MB 00:00:08
从 https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg 检索密钥
导入 GPG key 0x621E9F35:
用户 ID : "Docker Release (CE rpm) <docker@docker.com>"
指纹 : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
- Running transaction check
- Running transaction test
- Transaction test succeeded
- Running transaction
- libselinux.x86_64 0:2.5-14.1.el7 libselinux-python.x86_64 0:2.5-14.1.el7 libselinux-utils.x86_64 0:2.5-14.1.el7 libsemanage.x86_64 0:2.5-14.el7 libsemanage-python.x86_64 0:2.5-14.el7 libsepol.x86_64 0:2.5-10.el7
- policycoreutils.x86_64 0:2.5-29.el7 policycoreutils-python.x86_64 0:2.5-29.el7 selinux-policy.noarch 0:3.13.1-229.el7_6.6 selinux-policy-targeted.noarch 0:3.13.1-229.el7_6.6 setools-libs.x86_64 0:3.3.8-4.el7
- mkdir /etc/docker
- VIM /etc/docker/daemon.JSON
- {
- "registry-mirrors":["https://registry.docker-cn.com"]
- }
- Docs: https://docs.docker.com
- Process: 19030 ExecStart=/usr/bin/dockerd -H unix:// (code=exited, status=1/FAILURE)
- Main PID: 19030 (code=exited, status=1/FAILURE)
- docker version
- [root@node1 yum.repos.d]# docker version
- Client:
- Version: 18.09.0
- API version: 1.39
- Go version: go1.10.4
- Git commit: 4d60db4
- Built: Wed Nov 7 00:48:22 2018
- OS/Arch: Linux/amd64
- Experimental: false
- Server: Docker Engine - Community
- Engine:
- Version: 18.09.0
- API version: 1.39 (minimum version 1.12)
- Go version: go1.10.4
- Git commit: 4d60db4
- Built: Wed Nov 7 00:19:08 2018
- OS/Arch: Linux/amd64
- Experimental: false
- [root@node1 yum.repos.d]#
- [root@node1 yum.repos.d]# docker info
- Containers: 0
- Running: 0
- Paused: 0
- Stopped: 0
- Images: 0
- Server Version: 18.09.0
- Storage Driver: overlay2
- Backing Filesystem: xfs
- Supports d_type: true
- Native Overlay Diff: true
- Logging Driver: JSON-file
- Cgroup Driver: cgroupfs
- Plugins:
- Volume: local
- Network: bridge host macvlan null overlay
- Log: awslogs Fluentd gcplogs gelf journald JSON-file local logentries splunk syslog
- Swarm: inactive
- Runtimes: runc
- Default Runtime: runc
- Init Binary: docker-init
- containerd version: c4446665cb9c30056f4998ed953e6d4ff22c7c39
- runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
- init version: fec3683
- Security Options:
- seccomp
- Profile: default
- Kernel Version: 3.10.0-693.el7.x86_64
- Operating System: CentOS Linux 7 (Core)
- OSType: Linux
- Architecture: x86_64
- CPUs: 1
- Total Memory: 7.64GiB
- Name: node1.weide.com
- ID: PHWK:UCCE:5GB6:WS7I:EAWC:6Q4J:GXQF:A5KJ:ZWXG:JEUO:YE5Z:QU6C
- Docker Root Dir: /var/lib/docker
- Debug Mode (client): false
- Debug Mode (server): false
- Registry: https://index.docker.io/v1/
- Labels:
- Experimental: false
- Insecure Registries:
- 127.0.0.0/8
- Registry Mirrors:
- https://registry.docker-cn.com/
- Live Restore Enabled: false
- Product License: Community Engine
- [root@node1 yum.repos.d]#
来源: http://www.bubuko.com/infodetail-2875348.html