Skip to content

Latest commit

 

History

History
68 lines (56 loc) · 1.7 KB

docker.md

File metadata and controls

68 lines (56 loc) · 1.7 KB

Docker 安装

  1. 查看当前是否已安装Docker
rpm -aq | grep docker
  1. 安装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
  1. 查看可用Docker版本
yum list docker-ce --showduplicates |sort -r
  1. 安装
yum install docker-ce-19.03.15-3.el7.x86_64
  1. 配置文件
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
  1. 重启并配置开机自启
systemctl restart docker
systemctl enable docker
  1. 卸载
yum remove docker-ce-19.03.15-3.el7.x86_64

Docker 清理

若创建容器时报错如下,则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