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 up -d --no-deps recreates one service and leaves its dependencies alone

Docker
~/tips/tip-docker-compose-up-no-deps

docker compose up -d --no-deps web

Recreates only the Compose service you name, without starting or touching the services it depends on.

When I change one line for one service in a Compose file, I want exactly that service to restart. Plain docker compose up -d web doesn’t quite promise that. The docs say up also starts any linked services unless they’re already running, so the services web depends on come along for the ride. For a stack with a database underneath, I’d rather say exactly what I want.

Add --no-deps and Compose only deals with the services you name. The docs describe it as “Don’t start linked services”:

docker compose up -d --no-deps web

Say you bumped the image tag of the web service and want only that container replaced. With --no-deps, Compose works on web alone and leaves the database out of it. It pairs nicely with a pull of just that service:

docker compose pull web
docker compose up -d --no-deps web

Compose still decides on its own whether web needs recreating, based on its config and image. If nothing changed it just leaves it running. Add --force-recreate when you want a fresh container anyway.

The caveat is in the name. Compose won’t start anything the service depends on, so if the database is stopped, web comes up without it and will probably crash or keep retrying. The depends_on conditions such as service_healthy are skipped too. I’d only reach for --no-deps when the rest of the stack is already up and healthy, and use plain docker compose up -d when you’re starting from scratch.

Further reading: docker compose up reference

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