Published on

How to load env file when running Docker Image

Authors

If you have lots of environmental variables that need to be set when starting a docker image via CLI then --env-file argument might be a good fit.

Let's assume that you have an .env file with the following variables

WEB_API_ROOT=https://api.example.com

You can easily include it when running it like this:

docker run --env-file ./.env example-image:latest

Happy running docker!