Bitpath

Lesson 1 · Unit 04

Configuration and secrets

One image for every environment, settings and secrets from outside

13 exercisesabout 3 min

What you practise

  • Settings from the environment, secrets kept out of images and layers, one image for every environment

Try a question from this lesson

Pick one

An image has the staging database address written into its code. It passed every test in staging. To run in production the address must change. What does that force?

Hint

Images are read-only. How do you change something that was built in?

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Build once, configure at start

The image holds what is the same everywhere: the app and what it needs to run.

What differs between environments is passed in when the container starts, as environment variables: -e NAME=value, or --env-file for a file of them. The app reads them at startup.

shell
docker run -d -e DB_HOST=db.staging \
  shop/api:1.4.0
docker run -d -e DB_HOST=db.prod \
  shop/api:1.4.0

Concept

Secrets stay out of images

An image gets copied: to a registry, to every server, to every teammate. Whoever can pull it can read every file in every layer.

docker history also prints the instructions that built it, with the values of ENV and ARG.

So a password, token or key is never built in. It is handed to the container when it starts.

10 more exercises in the app

  • 1× type the answer
  • 5× multiple choice
  • 1× true or false
  • 1× fill the blanks
  • 1× match the pairs
  • 1× order the lines

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy