安装Docker

CentOS 7安装Docker

1
2
3
4
5
yum install -y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce

systemctl enable --now docker

安装Docker Compose

1
2
3
4
curl -L "https://github.com/docker/compose/releases/download/v2.29.7/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

chmod a+x /usr/local/bin/docker-compose
docker-compose version

配置加速镜像

1
2
3
4
5
6
7
8
9
10
11
12
13
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors": [
"https://registry.cn-shanghai.aliyuncs.com"
],
"insecure-registries": [
"docker.njito.com"
]
}
EOF

systemctl daemon-reload
systemctl restart docker
  • insecure-registries:默认情况下,Docker只允许通过https与镜像仓库通信,insecure-registries允许Docker与此项中的镜像仓库使用http或自签名证书进行通信。