Docker Community Forums

Share and learn in the Docker community.

.env file not read

I have a .env file I’m trying to use in a Docker Compose file to pass to the container to be used in the entrypoint script defined in the Dockerfile.

I have the following effective Dockerfile (spread out over two files, one override). The file is in the same directory as the docker compose files. The environment variable value is not getting passed to the container. When I add “=${RUN_MIGRATIONS_ON_START}”, the variable value is blank. If I leave that off, then the variables aren’t even set in the container.

Docker compose files:

Main docker compose file:

version: '3.4'

      context: .

Override docker compose file:

version: '3.4'


Did you see the following?

Also, the other posts in that topic may help debugging.

And as for:

I don’t know what that implies.

People blindly use random versions, without understanding the impact. Version 2.x was designed for docker-compose and provides EVERYTHING docker-compose is able to use, except “secrets:”, which for whatever reason seem to work with 3.x schemas - I always felt this is a bug, since docker run is not able to use secrets, and docker-compose is a 1:1 mapping - except in this case.

The whole resource constraint section in 3.x schmas is ignored by docker-compose, low level features like umask, privileged and many more do not work with 3.x when using docker-compose.