DELAPARRA
Index
Color
NL
Category: Docker

environment

Explained by Updated

What is environment?

environment: Sets environment variables for a service, as a list or a map. Often paired with an env_file. In Docker Compose, environment sets environment variables for a service. You can write them as a list, - APP_ENV=production, or as a map, APP_ENV: production. It is often combined with env_file, which loads variables from a file such as .env. Values in environment take priority, which is handy for overriding one setting per service.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about environment

What should you keep in mind with environment?

Keep secrets out of the Compose file itself, especially if it is committed to Git. Reference variables from your shell or an env file instead, as in DB_PASSWORD: ${DB_PASSWORD}. Add the .env file to .gitignore and commit a .env.example with placeholder values. That way a new developer knows which settings exist, without anyone sharing real passwords through the repository.

What does an example of environment look like?

services: web: environment: NODE_ENV: production DATABASE_URL: postgres://db:5432/app

At a glance

CategoryDocker
Explained by
Updated

More Docker terms

All terms starting with E

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.