一、配置镜像源
# wget http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo //配置阿里docker源
二、安装
# yum -y install docker-ce-18.06.1.ce-3.el7
# systemctl daemon-reload && systemctl start docker && systemctl enable docker
# docker --version
Docker version 18.06.1-ce, build e68fc7a
三、docker镜像加速
# sudo tee /etc/docker/daemon.json <<-'EOF'
{
"exec-opts": ["native.cgroupdriver=systemd"], #文件驱动(k8s默认是systemd,而docker默认是cgroupfs)
"registry-mirrors": ["https://tjshptqn.mirror.aliyuncs.com"], # 镜像加速
"insecure-registries": ["docker.harbor.com"], # 配置默认镜像仓库
"max-concurrent-downloads": 10,
"max-concurrent-uploads": 5,
"log-driver":"json-file",
"log-opts": { # 容器日志管理限制
"max-size": "300m",
"max-file": "2"
}
"live-restore": true #重启进程不会影响容器
}
EOF
registry-mirrors:镜像仓库
exec-opts:文件驱动(k8s默认是systemd,而docker默认是cgroupfs)
log-driver:日志驱动程序(docker默认就是json-file, 日志默认存放路径: /var/lib/docker/containers//-json.log)
log-opts:设置日志存储策略(max-size单容器日志上限500m; max-file单容器最多保留3份日志文件,分别是id+.json、id+1.json、id+2.json)
systemctl daemon-reload && systemctl restart docker && systemctl enable docker
四、docker卸载
1、查询docker安装过的包:
yum list installed | grep docker
2、删除安装包:
yum remove docker-ce.x86_64 docker-ce-cli.x86_64 -y
3、删除镜像/容器等
rm -rf /var/lib/docker