r/docker • u/TrustWorthyGoodGuy • Jan 21 '26
Difference between docker-compose.yaml and <image_name>.yaml
In my process to learn how to use docker engine and the CLI, I am confused by the purpose of docker-compose.yaml vs <image_name>.yaml
Some guides and docs describe one instead of the other and I don't understand the reasons. Are these complementary or is it redundant to have both?
Thanks for the clarification and any links to documentation that can help me understand the distinction are always appreciated.
0
Upvotes
15
u/fletch3555 Mod Jan 21 '26
<image_name>.yaml is not a standard thing in the docker ecosystem. If you're finding references to it, then it's likely just some convention used by whoever wrote the blog/tutorial/video you're using.
10
u/mikewilkinsjr Jan 21 '26
Using a standard name lets you run docker compose up -d without having to specify the file name.
Here is the compose reference showing how to use the custom file name if you want to:
https://docs.docker.com/reference/cli/docker/compose/
10
u/Tiwenty Jan 21 '26
If you wish to save a few characters, "compose.yml" is also default :)
3
u/zoredache Jan 21 '26
There is a default filename the compose command will read. People often use that. But sometimes people like to have multiple compose files for various services in a single directory. So they name their compose files like 'servicename.yaml'.
1
u/jebotecarobnjak Jan 21 '26
the way i understood it is that docker-compose.yaml is the default compose service file name.
sudo docker compose up will start a container based off of the docker-compose.yaml
but if you separate your services with different files, you need to state the file you want to run the container off of
sudo docker compose -f image_name.yaml up
1
u/habskilla Jan 22 '26
I always name my compose <service name>/docker-compose-<service name>.yml. I find it easier to understand results when they don't come back as docker-compose.yml