美文网首页
CentOS 8安装Docker

CentOS 8安装Docker

作者: clam314 | 来源:发表于2020-05-13 00:58 被阅读0次

一、Docker的安装

1.1、安装相关依赖

[woods@localhost ~]$ yum install -y yum-utils
错误:该命令必须以 root 用户运行
[woods@localhost ~]$ sudo yum install -y yum-utils
CentOS-8 - AppStream                                   6.2 kB/s | 4.3 kB     00:00    
CentOS-8 - Base                                        123  B/s | 3.9 kB     00:32    
CentOS-8 - Extras                                      952  B/s | 1.5 kB     00:01    
依赖关系解决。
=======================================================================================
 软件包               架构              版本                   仓库               大小
=======================================================================================
安装:
 yum-utils            noarch            4.0.8-3.el8            BaseOS             64 k

事务概要
=======================================================================================
安装  1 软件包

总下载:64 k
安装大小:19 k
下载软件包:
yum-utils-4.0.8-3.el8.noarch.rpm                       360 kB/s |  64 kB     00:00    
---------------------------------------------------------------------------------------
总计                                                    84 kB/s |  64 kB     00:00     
警告:/var/cache/dnf/BaseOS-929b586ef1f72f69/packages/yum-utils-4.0.8-3.el8.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 8483c65d: NOKEY
CentOS-8 - Base                                        1.6 MB/s | 1.6 kB     00:00    
导入 GPG 公钥 0x8483C65D:
 Userid: "CentOS (CentOS Official Signing Key) <security@centos.org>"
 指纹: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
 来自: /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                        1/1 
  安装    : yum-utils-4.0.8-3.el8.noarch                                           1/1 
  运行脚本: yum-utils-4.0.8-3.el8.noarch                                           1/1 
  验证    : yum-utils-4.0.8-3.el8.noarch                                           1/1 

已安装:
  yum-utils-4.0.8-3.el8.noarch                                                         

完毕!
[woods@localhost ~]$ 

1.2、查看Docker版本

[woods@localhost ~]$ sudo yum list docker-ce --showduplicates | sort -r
[sudo] woods 的密码:
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.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.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
Docker CE Stable - x86_64                       2.0 kB/s |  22 kB     00:11    
上次元数据过期检查:0:00:09 前,执行于 2020年05月12日 星期二 10时35分48秒。
可安装的软件包
[woods@localhost ~]$ 

1.3、安装Docker(docker-ce是社区版 与 ee是企业版)

安装docker-ce(docker服务器)、docker-ce-cli(docer客户端)和 containerd.io(用于管理主机系统的完整容器生命周期,从映像传输和存储到容器执行和监视,再到底层存储、网络附件等等):

[woods@localhost ~]$ sudo yum install docker-ce
[sudo] woods 的密码:
上次元数据过期检查:0:07:07 前,执行于 2020年05月12日 星期二 10时35分48秒。
错误:
 问题: package docker-ce-3:19.03.8-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
  - cannot install the best candidate for the job
  - package containerd.io-1.2.10-3.2.el7.x86_64 is excluded
  - package containerd.io-1.2.13-3.1.el7.x86_64 is excluded
  - package containerd.io-1.2.2-3.3.el7.x86_64 is excluded
  - package containerd.io-1.2.2-3.el7.x86_64 is excluded
  - package containerd.io-1.2.4-3.1.el7.x86_64 is excluded
  - package containerd.io-1.2.5-3.1.el7.x86_64 is excluded
  - package containerd.io-1.2.6-3.3.el7.x86_64 is excluded
(尝试添加 '--skip-broken' 来跳过无法安装的软件包 或 '--nobest' 来不只使用最佳选择的软件包)
[woods@localhost ~]$ 

1.3.1发生containerd.io软件包版本过低的问题,解决方法:

1、安装低版本的docker(1.2可以查看docket的版本) yum -y install docker-ce-18.06.0.ce-3.el7
2、升级 containerd.io软件包(可以到这个网站https://download.docker.com/linux/centos/7/x86_64/stable/Packages/,找到最新的去安装)

[woods@localhost ~]$ sudo dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
上次元数据过期检查:0:26:58 前,执行于 2020年05月12日 星期二 10时35分48秒。
containerd.io-1.2.6-3.3.el7.x86_64.rpm                 154 kB/s |  26 MB     02:51    
依赖关系解决。
=======================================================================================
 软件包                架构           版本                  仓库                  大小
=======================================================================================
安装:
 containerd.io         x86_64         1.2.6-3.3.el7         @commandline          26 M
     替换  runc.x86_64 1.0.0-60.rc8.module_el8.1.0+237+63e26edc

事务概要
=======================================================================================
安装  1 软件包

总计:26 M
确定吗?[y/N]: y
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                        1/1 
  安装    : containerd.io-1.2.6-3.3.el7.x86_64                                     1/2 
  运行脚本: containerd.io-1.2.6-3.3.el7.x86_64                                     1/2 
  废弃    : runc-1.0.0-60.rc8.module_el8.1.0+237+63e26edc.x86_64                   2/2 
  运行脚本: runc-1.0.0-60.rc8.module_el8.1.0+237+63e26edc.x86_64                   2/2 
  验证    : containerd.io-1.2.6-3.3.el7.x86_64                                     1/2 
  验证    : runc-1.0.0-60.rc8.module_el8.1.0+237+63e26edc.x86_64                   2/2 

已安装:
  containerd.io-1.2.6-3.3.el7.x86_64                                                   

完毕!
[woods@localhost ~]$ 

1.3.2发生错误:事务检查错误: 这是因为已经安装了podman,与podman-manpages包冲突

[woods@localhost ~]$ sudo yum install docker-ce docker-ce-cli
CentOS-8 - AppStream                                   621  B/s | 4.3 kB     00:07    
CentOS-8 - Base                                        1.6 kB/s | 3.9 kB     00:02    
CentOS-8 - Extras                                      2.4 kB/s | 1.5 kB     00:00    
Docker CE Stable - x86_64                              8.2 kB/s | 3.5 kB     00:00    
依赖关系解决。
=======================================================================================
 软件包              架构         版本                    仓库                    大小
=======================================================================================
安装:
 docker-ce           x86_64       3:19.03.8-3.el7         docker-ce-stable        25 M
 docker-ce-cli       x86_64       1:19.03.8-3.el7         docker-ce-stable        40 M
安装依赖关系:
 libcgroup           x86_64       0.41-19.el8             BaseOS                  70 k

事务概要
=======================================================================================
安装  3 软件包

总下载:64 M
安装大小:273 M
确定吗?[y/N]: y
下载软件包:
(1/3): libcgroup-0.41-19.el8.x86_64.rpm                398 kB/s |  70 kB     00:00    
(2/3): docker-ce-19.03.8-3.el7.x86_64.rpm              392 kB/s |  25 MB     01:04    
(3/3): docker-ce-cli-19.03.8-3.el7.x86_64.rpm          554 kB/s |  40 MB     01:13    
---------------------------------------------------------------------------------------
总计                                                   880 kB/s |  64 MB     01:14     
运行事务检查
事务检查成功。
运行事务测试
下载的软件包保存在缓存中,直到下次成功执行事务。
您可以通过执行 'dnf clean packages' 删除软件包缓存。
错误:事务检查错误:
  file /usr/share/man/man1/docker-attach.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-build.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-commit.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-container-prune.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-container.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-cp.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-create.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-diff.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-events.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-exec.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-export.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-history.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-image-prune.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-image.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-images.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-import.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-info.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-inspect.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-kill.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-load.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-login.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-logout.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-logs.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-pause.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-port.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-ps.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-pull.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-push.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-restart.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-rm.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-rmi.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-run.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-save.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-search.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-start.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-stats.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-stop.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-system-df.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-system-prune.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-system.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-tag.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-top.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-unpause.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-version.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-volume-create.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-volume-inspect.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-volume-ls.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-volume-prune.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-volume-rm.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-volume.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker-wait.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch
  file /usr/share/man/man1/docker.1.gz from install of docker-ce-cli-1:19.03.8-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch

[woods@localhost ~]$ 

解决方法:卸载podman

woods@localhost ~]$ rpm -q podman
podman-1.4.2-5.module_el8.1.0+237+63e26edc.x86_64
[woods@localhost ~]$ sudo dnf remove podman
[sudo] woods 的密码:
模块依赖问题

 问题 1: conflicting requests
  - nothing provides module(perl:5.26) needed by module perl-DBD-SQLite:1.58:8010020191114033549:073fa5fe-0.x86_64
 问题 2: conflicting requests
  - nothing provides module(perl:5.26) needed by module perl-DBI:1.641:8010020191113222731:16b3ab4d-0.x86_64
依赖关系解决。
=======================================================================================
 软件包           架构   版本                                         仓库        大小
=======================================================================================
移除:
 podman           x86_64 1.4.2-5.module_el8.1.0+237+63e26edc          @AppStream  51 M
移除依赖的软件包:
 cockpit-podman   noarch 4-1.module_el8.1.0+237+63e26edc              @AppStream 5.1 M
清除未被使用的依赖关系:
 libvarlink       x86_64 18-3.el8                                     @anaconda  129 k
 oci-systemd-hook x86_64 1:0.1.15-2.git2d0b8a3.module_el8.1.0+237+63e26edc
                                                                      @AppStream  74 k
 podman-manpages  noarch 1.4.2-5.module_el8.1.0+237+63e26edc          @AppStream 134 k

事务概要
=======================================================================================
移除  5 软件包

将会释放空间:56 M
确定吗?[y/N]: y
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                        1/1 
  运行脚本: cockpit-podman-4-1.module_el8.1.0+237+63e26edc.noarch                  1/1 
  删除    : cockpit-podman-4-1.module_el8.1.0+237+63e26edc.noarch                  1/5 
  删除    : podman-1.4.2-5.module_el8.1.0+237+63e26edc.x86_64                      2/5 
  运行脚本: podman-1.4.2-5.module_el8.1.0+237+63e26edc.x86_64                      2/5 
  删除    : podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch             3/5 
  删除    : oci-systemd-hook-1:0.1.15-2.git2d0b8a3.module_el8.1.0+237+63e26edc.x   4/5 
  删除    : libvarlink-18-3.el8.x86_64                                             5/5 
  运行脚本: libvarlink-18-3.el8.x86_64                                             5/5 
  验证    : cockpit-podman-4-1.module_el8.1.0+237+63e26edc.noarch                  1/5 
  验证    : libvarlink-18-3.el8.x86_64                                             2/5 
  验证    : oci-systemd-hook-1:0.1.15-2.git2d0b8a3.module_el8.1.0+237+63e26edc.x   3/5 
  验证    : podman-1.4.2-5.module_el8.1.0+237+63e26edc.x86_64                      4/5 
  验证    : podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch             5/5 

已移除:
  podman-1.4.2-5.module_el8.1.0+237+63e26edc.x86_64                                    
  cockpit-podman-4-1.module_el8.1.0+237+63e26edc.noarch                                
  libvarlink-18-3.el8.x86_64                                                           
  oci-systemd-hook-1:0.1.15-2.git2d0b8a3.module_el8.1.0+237+63e26edc.x86_64            
  podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch                           

完毕!
[woods@localhost ~]$

1.3.3正常安装docker-ce 和 docker-cli

[woods@localhost ~]$ sudo yum install docker-ce docker-ce-cli -y
上次元数据过期检查:0:19:00 前,执行于 2020年05月12日 星期二 11时30分20秒。
依赖关系解决。
=======================================================================================
 软件包              架构         版本                    仓库                    大小
=======================================================================================
安装:
 docker-ce           x86_64       3:19.03.8-3.el7         docker-ce-stable        25 M
 docker-ce-cli       x86_64       1:19.03.8-3.el7         docker-ce-stable        40 M
安装依赖关系:
 libcgroup           x86_64       0.41-19.el8             BaseOS                  70 k

事务概要
=======================================================================================
安装  3 软件包

总计:64 M
安装大小:273 M
下载软件包:
[SKIPPED] libcgroup-0.41-19.el8.x86_64.rpm: Already downloaded                        
[SKIPPED] docker-ce-19.03.8-3.el7.x86_64.rpm: Already downloaded                      
[SKIPPED] docker-ce-cli-19.03.8-3.el7.x86_64.rpm: Already downloaded                  
---------------------------------------------------------------------------------------
总计                                                   6.3 GB/s |  64 MB     00:00     
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                        1/1 
  安装    : docker-ce-cli-1:19.03.8-3.el7.x86_64                                   1/3 
  运行脚本: docker-ce-cli-1:19.03.8-3.el7.x86_64                                   1/3 
  运行脚本: libcgroup-0.41-19.el8.x86_64                                           2/3 
  安装    : libcgroup-0.41-19.el8.x86_64                                           2/3 
  运行脚本: libcgroup-0.41-19.el8.x86_64                                           2/3 
  安装    : docker-ce-3:19.03.8-3.el7.x86_64                                       3/3 
  运行脚本: docker-ce-3:19.03.8-3.el7.x86_64                                       3/3 
  验证    : libcgroup-0.41-19.el8.x86_64                                           1/3 
  验证    : docker-ce-3:19.03.8-3.el7.x86_64                                       2/3 
  验证    : docker-ce-cli-1:19.03.8-3.el7.x86_64                                   3/3 

已安装:
  docker-ce-3:19.03.8-3.el7.x86_64         docker-ce-cli-1:19.03.8-3.el7.x86_64        
  libcgroup-0.41-19.el8.x86_64            

完毕!
[woods@localhost ~]$ 

二、启动Docker

2.1、systemctl start docker启动docker,及ps aux |grep dockersystemctl status docker查看进程是否运行

[woods@localhost ~]$ sudo systemctl start docker
[woods@localhost ~]$ ps aux |grep docker
root      37534  0.6 10.1 775144 83240 ?        Ssl  11:52   0:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
woods     37667  0.0  0.1  12320   992 pts/0    R+   11:53   0:00 grep --color=auto docker
[woods@localhost ~]$ systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: di>
   Active: active (running) since Tue 2020-05-12 11:52:50 EDT; 1min 3s ago
     Docs: https://docs.docker.com
 Main PID: 37534 (dockerd)
    Tasks: 8
   Memory: 91.6M
   CGroup: /system.slice/docker.service
           └─37534 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.s>
lines 1-9/9 (END)

2.2、systemctl enable docker设置开机自启动docker

[woods@localhost ~]$ systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[woods@localhost ~]$ systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: dis>
   Active: active (running) since Tue 2020-05-12 11:52:50 EDT; 12min ago
     Docs: https://docs.docker.com
 Main PID: 37534 (dockerd)
    Tasks: 8
   Memory: 43.4M
   CGroup: /system.slice/docker.service
           └─37534 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.s>
lines 1-9/9 (END)

2.3、确认docker版本

[woods@localhost ~]$ docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:27:04 2020
 OS/Arch:           linux/amd64
 Experimental:      false
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/version: dial unix /var/run/docker.sock: connect: permission denied
[woods@localhost ~]$ 

2.3.1免sudo使用docker

[woods@localhost ~]$ sudo groupadd docker //添加一个docker属组(如果没有)
[sudo] woods 的密码:
groupadd:“docker”组已存在
[woods@localhost ~]$ sudo gpasswd -a ${USER} docker //将用户加入该group中,退出并重新登陆
正在将用户“woods”加入到“docker”组中
[woods@localhost ~]$ exit

从新登录(打开终端)

[woods@localhost ~]$ sudo service docker restart //重启docker服务
[sudo] woods 的密码:
Redirecting to /bin/systemctl restart docker.service
[woods@localhost ~]$ newgrp - docker //切换当前会话到新group或重启会话
[woods@localhost ~]$  docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:27:04 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:25:42 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
[woods@localhost ~]$ 

三、安装Docker-compose

利用pip3直接安装

[woods@localhost ~]$ sudo pip3 install docker-compose
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
……
Installing collected packages: dockerpty, cached-property, pyrsistent, attrs, zipp, importlib-metadata, jsonschema, websocket-client, pynacl, cryptography, bcrypt, paramiko, docker, texttable, docopt, docker-compose
  Running setup.py install for dockerpty ... done
  Running setup.py install for pyrsistent ... done
  Running setup.py install for docopt ... done
Successfully installed attrs-19.3.0 bcrypt-3.1.7 cached-property-1.5.1 cryptography-2.9.2 docker-4.2.0 docker-compose-1.25.5 dockerpty-0.4.1 docopt-0.6.2 importlib-metadata-1.6.0 jsonschema-3.2.0 paramiko-2.7.1 pynacl-1.3.0 pyrsistent-0.16.0 texttable-1.6.2 websocket-client-0.57.0 zipp-3.1.0
[woods@localhost ~]$  docker-compose version
docker-compose version 1.25.5, build unknown
docker-py version: 4.2.0
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.1.1c FIPS  28 May 2019
[woods@localhost ~]$ 

相关文章

网友评论

      本文标题:CentOS 8安装Docker

      本文链接:https://www.haomeiwen.com/subject/rbqwnhtx.html