brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: docker compose down --rmi local removes the images a project built

Docker
~/tips/tip-docker-compose-down-rmi-local

docker compose down --rmi local

Stops and removes a Compose project and deletes images that have no custom tag.

docker compose down removes containers and networks and leaves the images behind. An option takes the images along.

This deletes images, so the next up has to build or pull them again.

docker compose down --rmi local

The Docker docs describe --rmi as removing the images used by services. The value local removes only images that do not have a custom tag, and all removes every image the services use.

By default down only removes the containers of the services in the Compose file, the networks defined in it and the default network if one is used. Networks and volumes defined as external are never removed. Anonymous volumes also stay, and since they have no stable name a later up does not mount them again.

Volumes are a separate flag, -v or --volumes. It removes the named volumes declared in the Compose file plus the anonymous volumes attached to containers, which means data is gone for good:

docker compose down -v

I keep that one out of anything I type from memory. To see what went, run docker compose images before and docker image ls after. An image that carries your own tag counts as custom and stays with local.

Further reading: Docker docs: docker compose down

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link