自动安装
卸载旧版本
# CentOS
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
# Debian
apt-get remove docker \
docker-engine \
docker.io
使用脚本自动安装
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh --mirror Aliyun
# sh get-docker.sh --mirror AzureChinaCloud
启动 Docker CE
#设置开机自启动
systemctl enable docker
#启动docker
systemctl start docker
或
service docker start
中国源
Docker很多镜像动不动就1G或几百M,官方经常掉线。所以只能换国内源。
国内的镜像源有
- docker官方中国区
https://registry.docker-cn.com
- 网易
http://hub-mirror.c.163.com
- ustc
http://docker.mirrors.ustc.edu.cn
- 阿里云
http://<你的ID>.mirror.aliyuncs.com
注意registry-mirrors
千万不要用https
,而是用http
,否则会显示No certs for egitstry.docker.com
,insecure-registries
不要任何http
头,否则无法通过。
通用的方法就是编辑/etc/docker/daemon.json
:
cat > /etc/docker/daemon.json<<-EOF
{
"registry-mirrors" : [
"http://ovfftd6p.mirror.aliyuncs.com",
"http://registry.docker-cn.com",
"http://docker.mirrors.ustc.edu.cn",
"http://hub-mirror.c.163.com"
],
"insecure-registries" : [
"registry.docker-cn.com",
"docker.mirrors.ustc.edu.cn"
],
"debug" : true,
"experimental" : true
}
EOF
然后重启docker的daemon即可。
systemctl restart docker