$blog++

How to clean up your environment when using docker

Mar/10/2019 1 min read by Marco Monteiro

After a few projects we all know that you can have a real mess on your rig. Specially when it comes to saving space. So how to do that?

For this purpose you can use following command:

$ docker system prune -a

This will give you the following output:

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

You can be even a bit more hardcore and shove a -a command in there, that will remove everything, not just the images.

If your purpose is just to force Docker to rebuild images without using cache then use following combination:

$ docker system prune
$ docker-compose build --no-cache

Then run up command as usual:

$ docker-compose up

Stay clean!

x

Like it? Tweet it.

"How to clean up your environment when using docker" via @marcogmonteiro