Mar 22

Docker Cleanup

After a time, Docker containers and images build up and can eat disk space. Failed docker build invocations can leave a lot of artifacts behind.

The following commands can help. Many of them say ‘not all containers could be removed’; this has to do with the header from docker ps. Usually this can be ignored.

Caveat: Docker images cannot be removed if they are in use by a container.

Remove Ended Containers Which Match a Pattern

Remove All Containers Which Match a Pattern

Remove Images Matching a Pattern

Remove Incomplete Images

Remove all containers except those currently running

Leave a Reply

%d bloggers like this: