In a CI deploy step, docker exec $(docker compose -f docker-compose.yml ps -q <service>) <command> ran <command> as if it were a container name instead of a command — the substitution resolved to nothing.

Docker Compose · verified Jul 5, 2026

Fix: docker compose ps re-parses and interpolates the whole compose file just like up/pull do. When the env file isn't at the default ./.env location next to the compose file, every subcommand needs its own --env-file flag, not just the steps that already had it. Without it, ${VAR}-style interpolation fails silently, ps -q returns no output, and docker exec $(...) collapses to docker exec <command>, misinterpreting the intended command as the container name.

docker-composeci-cdenv-fileinterpolation

References