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: a Docker Compose dry run shows what a command would create or remove

Docker
~/tips/tip-docker-compose-dry-run

docker compose --dry-run up -d

Preview which containers and networks a Compose command would create, stop or remove.

Before you run down on a project you did not set up yourself, it is nice to know what will go. The global --dry-run flag runs a Compose command without changing anything.

docker compose --dry-run up -d
docker compose --dry-run down -v

The output looks like a normal run: networks being created, containers being created and started, or stopped and removed. None of it actually happens. I find it most useful for down with extra flags, where a typo can take a volume with it, and for up on a machine where you want to know which services would be recreated.

The flag works with most subcommands, including pull, build, rm and restart. You can also put it after the subcommand, as in docker compose up --dry-run.

It is a simulation, so it can miss problems that only appear for real: a port that is already taken on the host, an image that fails to pull, or a container that crashes on start. Treat a clean dry run as a preview of the plan, not as proof that the stack will come up. For checking the file itself, docker compose config is still the better first step.

Further reading: docker compose

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