docker 笔记

安装

https://yeasy.gitbooks.io/docker_practice/install/ubuntu.html

卸载

To completely uninstall Docker:

Step 1

dpkg -l | grep -i docker

To identify what installed package you have:

Step 2

sudo apt-get purge -y docker-engine docker docker.io docker-ce  
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce  

The above commands will not remove images, containers, volumes, or user created configuration files on your host. If you wish to delete all images, containers, and volumes run the following commands:

sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock

You have removed Docker from the system completely.

删除/停止容器

现在的docker有了专门清理资源(container、image、网络)的命令。 

docker 1.13 中增加了 docker system prune的命令,针对container、image可以使用docker container prune、docker image prune命令。

删除所有不使用的镜像

docker image prune --force --all
# 或下面
docker image prune -f -a

删除所有停止的容器

docker container prune -f

列出所有的容器 ID

docker ps -aq

停止所有的容器

docker stop $(docker ps -aq)

删除所有的容器

docker rm $(docker ps -aq)

删除所有的镜像

docker rmi $(docker images -q)

0 Comments (59 Views)

Leave a Reply

Your email address will not be published. Required fields are marked *