Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose override not taking additional yml into account?

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

like image 720
membersound Avatar asked Oct 17 '25 10:10

membersound


1 Answers

According to the documentation, docker-compose will only automatically find files named docker-compose.yml and docker-compose.override.yml:

By default, Compose reads two files, a docker-compose.yml and an optional docker-compose.override.yml file. By convention, the docker-compose.yml contains your base configuration. The override file, as its name implies, can contain configuration overrides for existing services or entirely new services.

If you want to use additional compose files, you need to specify them explicitly using -f <filename>:

docker-compose up -f docker-compose.yml -f docker-compose.test.yml
like image 56
larsks Avatar answered Oct 19 '25 08:10

larsks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!