Docker 安装
### CentOS8 默认是会读取centos.org的mirrorlist的,所以一般来说是不需要配置镜像的。
### (Refer to: https://www.linuxidc.com/Linux/2019-10/161212.htm)
# step 1: 安装必要的一些系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# step 2: 更新 container.io 包, 否则可能会报 `package docker-ce-3:19.03.13-3.el7.x86_64 requires containerd.io >= 1.2.2-3, ...`的错
# 可在 https://mirrors.aliyun.com/docker-ce/linux/centos/8/x86_64/stable/Packages/ 下找最新版安装
sudo dnf install -y --allowerasing https://mirrors.aliyun.com/docker-ce/linux/centos/8/x86_64/stable/Packages/containerd.io-1.3.7-3.1.el8.x86_64.rpm
# Step 3: 安装Docker-CE
sudo yum install -y docker-ce
# Step 4: 开启Docker服务并设置开机自启
sudo systemctl start docker && sudo systemctl enable docker
# 测试, 如输出下图结果则安装成功
docker version
image.png
Docker-compose 安装
# 方法一 (Refer to: https://docs.docker.com/compose/install/)
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
# 方法二 (Refer to: https://docs.docker.com/compose/install/#install-using-pip)
sudo pip3 install docker-compose
# 测试, 如输出下图结果则安装成功
docker-compose --version
# 输出:docker-compose version 1.27.4, build xxx
image.png
国内镜像配置
- 编辑 /etc/docker/daemon.json 加入下列配置:
Notice: 如果有阿里云 docker hub mirror 账号的,可以将 https://registry.cn-hangzhou.aliyuncs.com/
替换成自己的 https://<你的ID>.mirror.aliyuncs.com
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"https://registry.cn-hangzhou.aliyuncs.com/",
"http://f1361db2.m.daocloud.io",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.ccs.tencentyun.com",
"http://hub-mirror.c.163.com"
]
}
- 重启 docker
sudo systemctl restart docker
网友评论