Docker Tip #43: Using the Docker Compose Config Command

Docker Compose supports ENV variable substitution and overriding YML files. The config command lets you see the true values being run.
If you run docker-compose config
, 2 really useful things will happen. First, your YML file will get a syntax check and secondly, Compose is going to resolve a “final” YML file which is the single source of truth of what actually gets run in the end.
That means, Compose will substitute any ENV variables that you’re using and load in ENV variables from env_files
while placing them in environment
. It also expands your volume paths to absolute paths and does a few other minor things.
So if you ever have something unexpected happen, such as a volume not working, or an environment variable being overwritten in an unexpected way then running docker-compose config
is your goto tool to troubleshoot that.
Also, if you’re using override files or secondary files, you can pass them in with the -f
flag as you would normally do. The config command will account for all of them. Nice!