liveBook · Manning

Env_file property

As explained in Learn Docker in a Month of Lunches, Second Edition

The Compose env_file property specifies a text file whose key/value lines are loaded into a service container as environment variables.

Use env_file in a Compose service when configuration should come from a separate text file. Compose reads each key=value line and loads the values into the container as environment variables. section 10.3

Configure it in three practical steps:

  • Create a text file such as ./config/logging.debug.env, with one environment variable per line. section 10.3
  • Reference the file under the service's env_file property; multiple components can share the same settings file instead of duplicating variables. section 10.3

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains the property, key=value parsing, sharing rationale, and log-based verification, but not file syntax beyond lines and equals signs.
Examples
Uses logging.debug.env and logging.information.env in todo-web development and Compose configurations.
What it assumes
Assumes familiarity with Compose services and environment variables while contrasting env_file with environment and secrets.
What you can do after
Operate/configure a Compose service with externalized environment variables and verify their effect through container logs.
How it connects
Connects environment variables with Compose services, application configuration, and secrets.

Also explained in

Compare how 2 books explain env_file property →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.