- 查看当前是否已安装Docker
rpm -aq | grep docker
- 安装Docker源
curl -o /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo?spm=a2c6h.25603864.0.0.29d84ca5jvb9YX
- 查看可用Docker版本
yum list docker-ce --showduplicates |sort -r
- 安装
yum install docker-ce-19.03.15-3.el7.x86_64
- 配置文件
mkdir /etc/docker
cat >/etc/docker/daemon.json <<EOF
{
"registry-mirrors":["https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn"],
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
- 重启并配置开机自启
systemctl restart docker
systemctl enable docker
- 卸载
yum remove docker-ce-19.03.15-3.el7.x86_64
若创建容器时报错如下,则Docker磁盘空间不足
Failed to create pod sandbox: rpc error: code = Unknown desc = failed to create a sandbox for pod "csi-node-5n8tg": Error response from daemon: devmapper: Thin Pool has 53522 free data blocks which is less than minimum required 163840 free data blocks. Create more free space in thin pool or use dm.min_free_space option to change behavior
#查看Docker详情
docker info
清理
#删除关闭的容器
docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs docker rm
#删除没有Tag的镜像
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
#删除dangling Volume
docker volume rm $(docker volume ls -qf dangling=true)
#或者使用以下命令清理,将删除当前不在运行的所有镜像容器网络volume
docker system prune