CentOS 8.1 安装docker

时间:2020-05-30
本文章向大家介绍CentOS 8.1 安装docker,主要包括CentOS 8.1 安装docker使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

参考 https://juejin.im/post/5e3032575188252c6e182a55

软件更新

把相关软件都更新

 yum update
卸载旧版本
yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

安装yum-utils软件包(提供yum-config-manager 实用程序)并设置稳定的存储库。

yum install -y yum-utils

yum -config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
查看Docker版本
yum list docker-ce --showduplicates | sort -r
安装Docker

报错

[root@localhost ~]# yum install docker-ce
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository AppStream is listed more than once in the configuration
上次元数据过期检查:0:00:38 前,执行于 2020年01月28日 星期二 17时02分33秒。
错误:
 问题: package docker-ce-3:19.03.5-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.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' 来不只使用最佳选择的软件包)


这个时候需要安装containerd.io,我们可以到这个网站https://download.docker.com/linux/centos/7/x86_64/stable/Packages/,找到最新的去安装

[root@localhost ~]# dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm

继续进行安装

[root@localhost ~]# yum install docker-ce docker-ce-cli
启动Docker,并设置为开机自启
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.

原文地址:https://www.cnblogs.com/z_lb/p/12993148.html