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 restart does not pick up changes to your Compose file

Docker
~/tips/tip-docker-compose-restart-no-reload

docker compose up -d

Use up -d after editing compose.yaml, because restart keeps the old settings.

You change an environment variable in compose.yaml, run docker compose restart, and nothing changes. That is expected behaviour, and it confuses a lot of people.

restart stops and starts the existing containers. The containers keep the configuration they were created with, so a new variable, port, volume or image tag never reaches them. The docs say it plainly: changes to the Compose file are not reflected after a restart.

What you want instead is:

docker compose up -d

Compose compares the file with the running containers and recreates only the services whose configuration changed. The others keep running untouched. For one service:

docker compose up -d web

restart still has its place in my view, but only for what it is good at: an app that needs a kick after it reread a config file from a mounted volume, or one that got stuck.

Recreating a container throws away anything it wrote outside its volumes. If an app keeps state in its own filesystem, that state is gone after up -d recreates it, and a restart would have kept it. Check your volumes before you rely on recreating, and use docker diff if you are unsure what the container writes.

Further reading: docker compose restart, docker compose up

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