Docker Cheat Sheet/Set environment variables

Pass environment variables into the container.

Section: Containers

Set environment variables

bash
bash
docker run -e NODE_ENV=production myapp:latest
Explanation

Can be repeated or loaded from a file with `--env-file`.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Containers
Load env file
Load environment variables from a file.
OpenIn sheetbashsame section
Run a container
Create and start a new container.
OpenIn sheetbashsame section
Run detached
Run a container in the background.
OpenIn sheetbashsame section
Run interactively
Run an interactive shell inside a new container.
OpenIn sheetbashsame section
Mount a bind volume
Bind-mount a host directory into the container.
OpenIn sheetbashsame section
Use explicit mount syntax
Mount storage using long-form syntax.
OpenIn sheetbashsame section