brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: list every variable a Docker Compose file needs before you start it

Docker
~/tips/tip-docker-compose-config-variables

docker compose config --variables

See which variables a project expects, which are required and their defaults.

Someone hands you a Compose file with a dozen ${...} placeholders. Before you start it, you want to know which of them you have to fill in. Compose can tell you.

docker compose config --variables

The output is a small table with the variable name, whether it is required, the default value and the alternate value. For a file like this:

services:
  db:
    image: mariadb:10.11
    environment:
      MARIADB_ROOT_PASSWORD: ${DB_PASS:?set DB_PASS}
      TZ: ${TZ:-UTC}

it reports DB_PASS as required with no default, and TZ as optional with UTC. That is the shopping list for your .env file.

What I like is that it works even when a required variable is missing. A normal docker compose config stops with an error at the first missing value, while this listing just shows you all of them at once.

It only knows about variables that appear in the Compose file. Settings that the image reads at runtime, like a PUID the app expects, are not listed unless the file mentions them, so the image documentation still matters. The flag is fairly new, so an older Compose version will reject it as unknown.

Further reading: docker compose config

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link