Can
Be Better

Centos8安装Docker以及Docker-Compose

一般系统选用centos7,但是centos8出来了,恰巧两台服务器都是centos8,官方curl -sSL https://get.docker.com | sh安装方式默认会报错的,所以特别记录一下。

[[email protected] ~]# curl -sSL https://get.docker.com | sh
# Executing docker install script, commit: f45d7c11389849ff46a6b4d94e0dd1ffebca32c1
+ sh -c 'yum install -y -q yum-utils'
+ sh -c 'yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo'
Adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
+ '[' stable '!=' stable ']'
+ sh -c 'yum makecache'
CentOS-8 - AppStream                                                                                                                                  1.5 kB/s | 4.3 kB     00:02    
CentOS-8 - Base                                                                                                                                       1.4 kB/s | 3.8 kB     00:02    
CentOS-8 - Extras                                                                                                                                     599  B/s | 1.5 kB     00:02    
Docker CE Stable - x86_64                                                                                                                             2.4 kB/s | 3.5 kB     00:01    
Extra Packages for Enterprise Linux 8 - x86_64                                                                                                        4.2 kB/s | 7.2 kB     00:01    
Metadata cache created.
+ '[' -n '' ']'
+ sh -c 'yum install -y -q docker-ce'
Error: 
 Problem: package docker-ce-3:19.03.3-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.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

报错信息显示需要安装containerd.io,所以正确的安装方式相比较CentOS7,会增加一个步骤。

国内加速安装

 

# install containerd.io
[[email protected] ~]# dnf install -y https://download.docker.com/linux/centos/7/x86_64/nightly/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm

# install docker-ce
[[email protected] ~]# curl -sSL https://get.docker.com | sh

官方慢速安装

 

# install containerd.io
[[email protected] ~]# dnf install -y https://download.docker.com/linux/centos/7/x86_64/nightly/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm

# install docker-ce
[[email protected] ~]# curl -sSL https://get.docker.com | sh

启动Docker

[[email protected] ~]# systemctl enable --now docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[[email protected] ~]# docker version
Client: Docker Engine - Community
Version:           19.03.3
API version:       1.40
Go version:        go1.12.10
Git commit:        a872fc2f86
Built:             Tue Oct  8 00:58:10 2019
OS/Arch:           linux/amd64
Experimental:      false

Server: Docker Engine - Community
Engine:
Version: 19.03.3
API version: 1.40 (minimum version 1.12)
Go version: go1.12.10
Git commit: a872fc2f86
Built: Tue Oct 8 00:56:46 2019
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

超暴力安装Docker-compose

# install docker-compose from daocloud mirror
[[email protected] ~]# curl -L https://get.daocloud.io/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
[[email protected] ~]# chmod +x /usr/local/bin/docker-compose

# makesure version
[[email protected] ~]# docker-compose version
docker-compose version 1.24.1, build 4667896b
docker-py version: 3.7.3
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.1.0j 20 Nov 2018

配置Docker加速

# use daocloud docker registry mirror
[[email protected] ~]# echo '{"registry-mirrors": ["http://f1361db2.m.daocloud.io"]}' >/etc/docker/daemon.json
[[email protected] ~]# systemctl restart docker

# makesure mirror
[[email protected] ~]# docker info
···
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
http://f1361db2.m.daocloud.io/
Live Restore Enabled: false

不开启评论,如有问题疑问请发邮件。[email protected]最长的路 » Centos8安装Docker以及Docker-Compose