52-technologies-in-2016 icon indicating copy to clipboard operation
52-technologies-in-2016 copied to clipboard

Week 39: Docker for Java Developers Part 1

Open shekhargulati opened this issue 9 years ago • 2 comments

Please provide your feedback by posting a comment against this issue.

shekhargulati avatar Oct 07 '16 15:10 shekhargulati

When you are building all kinds of docker images, you may end up with a lot of untagged images, volumes. A trick I used in my own projects is a bash function like this.

# docker clean up, remove all stopped containers and untagged images
# http://jimhoskins.com/2013/07/27/remove-untagged-docker-images.html
# https://github.com/chadoe/docker-cleanup-volumes
# https://www.calazan.com/docker-cleanup-commands/
docker-cleanup() {
    docker rm $(docker ps -a -q);
    docker rmi $(docker images -q -f dangling=true);
    docker volume rm $(docker volume ls -qf dangling=true)
}

Most of the times, just removing the stopped containers is good enough. But it's nice to have something to clean up locally.

soleo avatar Oct 10 '16 16:10 soleo

@soleo thanks. I have added it to the blog.

shekhargulati avatar Oct 10 '16 17:10 shekhargulati