Clean Docker Environment

In my fight with docker I need to have a clean environment. Here is how to get one:

List all containers (only IDs)

docker ps -aq 

Stop all running containers

docker stop $(docker ps -aq) 

Remove all containers

docker rm $(docker ps -aq) 

Remove all images

docker rmi $(docker images -q) 

Remove all networks

docker network rm $(docker network ls)

All together

docker ps -aq ;\
docker stop $(docker ps -aq) ;\
docker rm $(docker ps -aq) ;\
docker rmi $(docker images -q) ;\
docker network rm $(docker network ls)

 
 
 
Posted in How to, Linux.

Leave a Reply

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