docker

自动安装

卸载旧版本

# 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

graphdriver

failed to start daemon: error initializing graphdriver: prior storage driver devicemapper is deprecated and will be removed in a future release; update the the daemon configuration and explicitly

修复方法:
nano /etc/docker/daemon.json

{ storage-driver: devicemapper }

保存- 重新启动 Docker.

一键添加:

cat > /etc/docker/daemon.json<<-EOF
{ storage-driver: devicemapper } 
EOF
systemctl restart docker