Why this behaviour difference between docker run and docker-compose?

Your compose file is an almost perfect translation of your docker run commands. Of course depends_on and build do not exist in docker run. But everything else is a 1:1 translation.

Usually when we see such a topic, users use arguments in their docker run commands that do not exist in the compose file, or have additional config items in their compose file that don’t exist as docker run argument.

Though, the one thing that I notice is that you use the deprecated docker-compose (=v1) command, instead of the docker compose (=v2) command. V2 will not care about the file schema version, and use the latest version.

You might want to try it again using docker compose.

1 Like