Skip to content

Docker resource cleanup workflow

The Docker resource cleanup workflow involves specific command sequences used to manage and remove system artifacts such as containers, images, volumes, and networks^[400-devops__03-Containerization__readme.md].

Workflow steps

Remove all containers and images

The most intensive cleanup step involves forcibly removing all containers, regardless of their state, and subsequently deleting all images^[400-devops__03-Containerization__readme.md].

This is typically achieved using two commands: docker rm -f $(docker ps -a -q) to remove all containers, followed by docker rmi -f $(docker images -q) to remove all images^[400-devops__03-Containerization__readme.md].

Remove unused volumes

To reclaim storage space used by volumes, the workflow includes a command to prune all volumes that are not currently in use by active containers^[400-devops__03-Containerization__readme.md].

The specific command used for this purpose is docker volume prune^[400-devops__03-Containerization__readme.md].

Remove unused networks

Similarly, unused networks can be removed from the system to clean up the networking stack^[400-devops__03-Containerization__readme.md].

This is executed using the command docker network prune^[400-devops__03-Containerization__readme.md].

  • [[Docker]]
  • DevOps
  • [[System Administration]]

Sources

  • 400-devops__03-Containerization__readme.md