Docker Community Forums

Share and learn in the Docker community.

Environment Variable substitution in .env file

Hi there,

I have a docker-compose file where I mount the SSH Authentication Socket as a volume to share the SSH Agent of the host system. However, because MacOS needs the magic path /run/host-services/ssh-auth.sock, I introduced an env var $SSH_CUSTOM_AUTH_SOCK that each developer can set in their local .env file. The MacOS developers set it to the magical path. The Linux users can just set it to whatever is $SSH_AUTH_SOCK.

However, I did the following in my local .env, which works like a charme (running on Ubuntu / WSL2)


However for another user running another Distro, the .env file does not seem to be parsed the same way, because SSH_AUTH_SOCK will not be replaced with the value of the environment variable.

Somewhere in the GitHub Issues I read that the .env file handling is loosely modeled after, which supports this way of writing your .env file.

Now, is this supposed to work and might this be bug, or did it just work by accident on my machine?

Any hint appreciated. Cheers.

1 Like