Loading `.env` files into a Docker container

Back to index
Date: 2021-06-04
Category: docker


An .env file that looks something like this:

MY_KEY=1234
HELLO_WORLD=akp

can be loaded into a Docker container as environment variables using the --env-file flag. For example, docker run --env-file container.env my-image and so on. This flag also works with the docker create command.

Source