Use Environment Variables

This is how you can pass environment variables into Docker containers.

Create Environment Variables

DB_NAME="staff_database"
DB_PASSWORD="funny cat dog mouse"

Create Container With Environment Variables

Create and start (docker run) Docker based on the Docker image python:3.8-slim. The container has access to two environment variables, DB_NAME and DB_PASSWORD (--env DB_NAME --env DB_PASSWORD).

docker run --env DB_NAME --env DB_PASSWORD python:3.8-slim