在主机与运维主机上:21、22、200 三台都要部署安装
1.下载镜像
[root@hdss-1-22 ~]#yum clean all
[root@hdss-1-22 ~]# curl -fsSL https://get.docker.com|bash -s docker --mirror Aliyun
# Executing docker install script, commit: 3d8fe77c2c46c5b7571f94b42793905e5b3e42e4
+ sh -c 'yum install -y -q yum-utils'
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
+ sh -c 'yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo'
Loaded plugins: fastestmirror, langpacks
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
+ '[' stable '!=' stable ']'
+ sh -c 'yum makecache'
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 9.5 kB 00:00:00
* base: mirror.bit.edu.cn
* epel: mirrors.bfsu.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirrors.bfsu.edu.cn
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/11): base/7/x86_64/filelists_db | 7.2 MB 00:00:00
(2/11): epel/x86_64/prestodelta | 330 B 00:00:00
(3/11): docker-ce-stable/7/x86_64/filelists_db | 24 kB 00:00:01
(4/11): base/7/x86_64/other_db | 2.6 MB 00:00:01
(5/11): docker-ce-stable/7/x86_64/other_db | 117 kB 00:00:01
(6/11): extras/7/x86_64/filelists_db | 224 kB 00:00:01
(7/11): updates/7/x86_64/filelists_db | 3.4 MB 00:00:00
(8/11): epel/x86_64/other_db | 3.3 MB 00:00:01
(9/11): epel/x86_64/filelists_db | 12 MB 00:00:03
(10/11): updates/7/x86_64/other_db | 454 kB 00:00:01
(11/11): extras/7/x86_64/other_db | 134 kB 00:00:02
Metadata Cache Created
+ '[' -n '' ']'
+ sh -c 'yum install -y -q docker-ce'
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.3-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-20.10.3-3.el7.x86_64.rpm is not installed
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) <[email protected]>"
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : https://download.docker.com/linux/centos/gpg
setsebool: SELinux is disabled.
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:
sudo usermod -aG docker your-user
Remember that you will have to log out and back in for this to take effect!
WARNING: Adding a user to the "docker" group will grant the ability to run
containers which can be used to obtain root privileges on the
docker host.
Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
for more information.
[root@hdss-1-22 ~]#
2.编辑daemon.json文件
[root@hdss-1-200 ~]# mkdir -p /etc/docker
[root@hdss-1-200 ~]# vi /etc/docker/daemon.json
{
"graph": "/data/docker",
"storage-driver": "overlay2",
"insecure-registries": ["registry.access.redhat.com","quay.io","harbor.od.com"],
"registry-mirrors": ["https://q2gr04ke.mirror.aliyuncs.com"],
"bip": "172.7.200.1/24",
"exec-opts": ["native.cgroupdriver=systemd"],
"live-restore": true
}
3.创建目录
[root@hdss-1-200 ~]# mkdir -p /data/docker
4.启动docker并设置开机自启
[root@hdss-1-21 ~]# systemctl start docker
[root@hdss-1-21 ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
5.查看容器是否启动
[root@hdss-1-22 ~]# docker version
Client: Docker Engine - Community
Version: 20.10.3
API version: 1.41
Go version: go1.13.15
Git commit: 48d30b5
Built: Fri Jan 29 14:34:14 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.3
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: 46229ca
Built: Fri Jan 29 14:32:37 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.3
GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
runc:
Version: 1.0.0-rc92
GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
docker-init:
Version: 0.19.0
GitCommit: de40ad0
[root@hdss-1-22 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@hdss-1-22 ~]#