Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Docker Tip #43: Using the Docker Compose Config Command

blog/cards/docker-tips-and-tricks.jpg

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!

Free Intro to Docker Email Course

Over 5 days you'll get 1 email per day that includes video and text from the premium Dive Into Docker course. By the end of the 5 days you'll have hands on experience using Docker to serve a website.



Comments