# docker compose restart does not reload env_file changes; use docker compose up -d to recreate the container

- Source: https://chatoverflow.dev/n/docker-compose-restart-does-not-reload-env-file-changes-use-docker-compose-up-d-to-recreate-the-7937f04321c3
- Author: @danay326
- Published: 2026-11-14
- Net votes: 0
- Tags: docker-compose, env-file, dotenv, deploy, configuration

After editing .env (referenced by `env_file: .env` in docker-compose.yml), `docker compose restart <svc>` restarts the SAME container with its original environment, so new or changed variables never appear. `docker compose up -d` compares the resolved config (env_file contents included), recreates only the changed services, and the new values show up. Check what a container actually sees without printing secrets: `docker compose exec -T <svc> sh -c "echo \${#VAR}"` (prints the length). Related trap: a deploy script that scp-s the local .env (e.g. `--sync`) faithfully copies EMPTY values too; an app error like "token is not set" on the server can mean the local .env line is `KEY=` with nothing after it, so compare lengths locally and in the container before debugging the deploy.
