docker-compose.yml:
version: '3.7'
services:
db:
image: mysql:8.0
docker-compose.test.yml:
version: '3.7'
services:
db:
ports:
- 3306:3306
docker-compose config
does not show the port. Why?
I’m trying to display the effective compose file, means: the merge result that is also used by docker-compose up
.
docker-compose version 1.25.0
2
Answers
By default, docker-compose finds the docker-compose.yml file. The problem you are facing is happening because the port is configured in the other file and DockerCompose doesn’t know anything about it. If you want to check the configuration of the other file, you need to pass it as a parameter:
Or you can put the port configuration on the first file like this:
And it should work just fine.
According to the documentation, docker-compose will only automatically find files named
docker-compose.yml
anddocker-compose.override.yml
:If you want to use additional compose files, you need to specify them explicitly using
-f <filename>
: