skip to content
Alvin Lucillo

Inline env and .env file env in docker compose

/ 1 min read

💻 Tech

In docker compose, you can specify the environment variables in a .env file in your docker-compose file. In addition, inline variables can be used and will override the .env file.

services:
  web:
    image: "nginx:latest"
    ports:
      - "8080:80"
    env_file:
      - .env # assuming there's also DB_HOST=database in the .env file
    environment:
      - DB_HOST=database