centos8安装docker

本文介绍在CentOS 8系统上安装Docker的步骤,并解决安装过程中遇到的事物检查错误问题,包括如何卸载Podman以避免冲突。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

centos8的系统进行docker的安装,废话不多说!

安装步骤:

1. 下载docker-ce的repo

curl https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo

2. 安装依赖(这是相比centos7的关键步骤)

yum install https://download.docker.com/linux/fedora/30/x86_64/stable/Packages/containerd.io-1.2.6-3.3.fc30.x86_64.rpm

3. 安装docker-ce

yum install docker-ce

4. 启动docker

systemctl start docker

 

出现错误问题

运行sudo yum install docker-ce docker-ce命令安装docker时会报Transaction check error事物检查错误,试了几遍也都是这个问题。

[root@localhost ~]# yum install docker-ce
上次元数据过期检查:0:39:07 前,执行于 2020年09月21日 星期一 21时08分10秒。
依赖关系解决。
===========================================================================================================
 软件包                   架构              版本                         仓库                         大小
===========================================================================================================
安装:
 docker-ce                x86_64            3:19.03.13-3.el7             docker-ce-stable             24 M
安装依赖关系:
 docker-ce-cli            x86_64            1:19.03.13-3.el7             docker-ce-stable             38 M
 libcgroup                x86_64            0.41-19.el8                  BaseOS                       70 k

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

总下载:63 M
安装大小:273 M
确定吗?[y/N]: y
下载软件包:
(1/3): libcgroup-0.41-19.el8.x86_64.rpm                                     84 kB/s |  70 kB     00:00    
(2/3): docker-ce-19.03.13-3.el7.x86_64.rpm                                  29 kB/s |  24 MB     14:16    
(3/3): docker-ce-cli-19.03.13-3.el7.x86_64.rpm                              39 kB/s |  38 MB     16:46    
-----------------------------------------------------------------------------------------------------------
总计                                                                        64 kB/s |  63 MB     16:47     
运行事务检查
事务检查成功。
运行事务测试
下载的软件包保存在缓存中,直到下次成功执行事务。
您可以通过执行 'yum clean packages' 删除软件包缓存。
错误:Transaction test error:
  file /usr/share/man/man1/docker-attach.1.gz from install of docker-ce-cli-1:19.03.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-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.13-3.el7.x86_64 conflicts with file from package podman-manpages-1.4.2-5.module_el8.1.0+237+63e26edc.noarch

发现是安装docker会与podman有冲突,所以需要先卸载podman再安装docker。

1.通过rpm -q podman命令查看本地环境中的podman信息

[root@localhost ~]# rpm -q podman
podman-1.4.2-5.module_el8.1.0+237+63e26edc.x86_64

2.载podman,dnf remove podman

[root@wuwl ~]# dnf remove podman
模块依赖问题

 问题 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.x86_64                               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.x86_64                               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                                                            

完毕!

3.安装docker

[root@localhost ~]# sudo yum install docker-ce docker-ce-cli containerd.io
上次元数据过期检查:1:08:39 前,执行于 2020年09月21日 星期一 21时08分10秒。
软件包 containerd.io-1.2.6-3.3.fc30.x86_64 已安装。
依赖关系解决。
===========================================================================================================
 软件包                   架构              版本                         仓库                         大小
===========================================================================================================
安装:
 docker-ce                x86_64            3:19.03.13-3.el7             docker-ce-stable             24 M
 docker-ce-cli            x86_64            1:19.03.13-3.el7             docker-ce-stable             38 M
安装依赖关系:
 libcgroup                x86_64            0.41-19.el8                  BaseOS                       70 k

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

总计:63 M
安装大小:273 M
确定吗?[y/N]: y
下载软件包:
[SKIPPED] libcgroup-0.41-19.el8.x86_64.rpm: Already downloaded                                            
[SKIPPED] docker-ce-19.03.13-3.el7.x86_64.rpm: Already downloaded                                         
[SKIPPED] docker-ce-cli-19.03.13-3.el7.x86_64.rpm: Already downloaded                                     
-----------------------------------------------------------------------------------------------------------
总计                                                                       6.1 GB/s |  63 MB     00:00     
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                            1/1 
  安装    : docker-ce-cli-1:19.03.13-3.el7.x86_64                                                      1/3 
  运行脚本: docker-ce-cli-1:19.03.13-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.13-3.el7.x86_64                                                          3/3 
  运行脚本: docker-ce-3:19.03.13-3.el7.x86_64                                                          3/3 
  验证    : libcgroup-0.41-19.el8.x86_64                                                               1/3 
  验证    : docker-ce-3:19.03.13-3.el7.x86_64                                                          2/3 
  验证    : docker-ce-cli-1:19.03.13-3.el7.x86_64                                                      3/3 

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

完毕!

 

 

 

 

 

### 如何在 CentOS 8安装 Docker 的逐步指南 要在 CentOS 8安装 Docker,可以遵循以下方法。此过程基于官方文档以及社区的最佳实践。 #### 添加 Docker 官方仓库 首先,在 CentOS 8 中需要设置 Docker 的官方存储库。这可以通过运行以下命令来完成: ```bash sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo ``` 这条命令会将 Docker 社区版的仓库添加到系统的包管理器配置文件中[^4]。 #### 更新系统并安装依赖项 为了确保兼容性和稳定性,建议先更新操作系统及其现有软件包: ```bash sudo dnf update -y && sudo dnf install -y yum-utils device-mapper-persistent-data lvm2 ``` 这些工具对于后续操作至关重要,特别是 `yum-utils` 和 LVM 工具集[^3]。 #### 安装 Docker CE (Community Edition) 一旦仓库被成功添加,就可以通过 DNF 包管理器直接安装最新版本的 Docker Community Edition: ```bash sudo dnf install docker-ce docker-ce-cli containerd.io ``` 上述命令不仅安装了核心容器引擎还包含了 CLI 接口和必要的 runtime 支持组件[^1]。 #### 启动并启用服务 安装完成后,启动 Docker 并将其设为开机自启的服务: ```bash sudo systemctl start docker sudo systemctl enable docker ``` 验证服务状态是否正常运行可执行如下指令: ```bash sudo systemctl status docker ``` 如果一切顺利,则应该看到绿色的 active(running) 提示信息。 #### 验证安装 最后一步是确认 Docker 是否能够正确工作。尝试拉取一个简单的测试镜像并运行它: ```bash sudo docker run hello-world ``` 该命令下载了一个小型测试容器,并打印一条消息表明环境已准备好使用。 以上就是在 CentOS 8 系统上部署 Docker 所需的主要步骤概述。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值