容器技术之Centos8安装Docker
容器技术之Centos8安装Docker一、Docker简介Docker的手册:https://docs.docker.com/install/linux/docker-ce/centos/Docker 是一个开源/246339)的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的 Linux或Windows 机器上,也可以实现虚拟化。容器是完全使用...
·
容器技术之Centos8
安装Docker
一、Docker
简介
Docker
的手册:https://docs.docker.com/install/linux/docker-ce/centos/
Docker 是一个开源/246339)的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的 Linux或Windows 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。
二、Docker
的安装
2.1. 删除旧的Docker
[root@localhost ~]# yum remove docker docker-common docker-selinux docker-engine
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
未找到匹配的参数: docker
未找到匹配的参数: docker-common
未找到匹配的参数: docker-selinux
未找到匹配的参数: docker-engine
没有软件包需要移除。
依赖关系解决。
无需任何处理。
完毕!
2.2. 安装相关依赖
[root@localhost ~]# yum install -y yum-utils \
> device-mapper-persistent-data \
> lvm2
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
CentOS-8 - Base 3.3 MB/s | 4.0 MB 00:01
Extra Packages for Enterprise Linux Modular 8 - x86_64 7.9 kB/s | 13 kB 00:01
软件包 device-mapper-persistent-data-0.8.5-2.el8.x86_64 已安装。
软件包 lvm2-8:2.03.05-5.el8.0.1.x86_64 已安装。
依赖关系解决。
==============================================================================================================================================
软件包 架构 版本 仓库 大小
==============================================================================================================================================
安装:
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 295 kB/s | 64 kB 00:00
----------------------------------------------------------------------------------------------------------------------------------------------
总计 87 kB/s | 64 kB 00:00
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 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
完毕!
2.3. 查看Docker
版本
[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
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
Extra Packages for Enterprise Linux Modular 8 - 6.1 kB/s | 9.4 kB 00:01
Extra Packages for Enterprise Linux 8 - x86_64 6.5 kB/s | 10 kB 00:01
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
2.4. 安装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
2.5. 启动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.
三、Docker-compose
安装
因为Centos
8就安装了Python3
和pip3
,所以直接安装就可以了。我在Centos7
用pip2
安装docker-compose
死活装不上,真的扎心!
[root@localhost ~]# pip3 -V
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)
[root@localhost ~]# pip3 install docker-compose
[root@localhost ~]# docker-compose version
docker-compose version 1.25.3, build unknown
docker-py version: 4.1.0
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.1.1c FIPS 28 May 2019
[root@localhost ~]#
四、修改Docker
下载源
登录阿里云:https://cr.console.aliyun.com/cn-hangzhou/mirrors。最后一栏就是镜像加速器。会有自己的镜像加速器地址。
选择Centos
进行执行:
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
五、欢迎关注下公众号
更多推荐
已为社区贡献2条内容
所有评论(0)