Day to Day Docker

Day to Day Docker

In this post i will include my day to day experiences with docker. This post can be used in future as a reference or a cheat sheet.

Stop All Containers

To stop all running containers use the docker container stop command followed by a list of all containers IDs.

docker container stop $(docker container ls -aq)

Deleting all the containers

docker rm $(docker ps -a -q) -f

Deleting all the volumes

Once all the containers are deleted, you can delete all the Docker volumes on your computer using the following command

docker volume prune

If you don't want to delete all the Docker volumes on your computer, you can search for a specific one and deleting it

docker volume ls
docker volume rm <name_of_volume>

Removing All Unused Objects

The docker system prune command will remove all stopped containers, all dangling images, and all unused networks:

docker system prune

You'll be prompted to continue, use the -f or --force flag to bypass the prompt.

WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all dangling images
  ``      - all build cache
Are you sure you want to continue? [y/N]

If you also want to remove all unused volumes, pass the --volumes flag:

docker system prune --volumes

Remove dangling images

Docker provides a docker image prune command that can be used to remove dangled and unused images. A dangling image is an image that is not tagged and is not used by any container. To remove dangling images type:

docker image prune

You'll be prompted to continue, use the -f or --force flag to bypass the prompt.

WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Avatar
Moshiour Rahman
Software Architect

My interests include enterprise software development, robotics, mobile computing and programmable matter.

comments powered by Disqus
Next
Previous

Related