title: How to override docker-compose values in multiple combined files?
body: <p>Letzt imagine i have 3 compose files (only focus on the mysql service)</p>
  <blockquote>
  <p>docker-compose.yml</p>
  <p>docker-compose.staging.yml</p>
  <p>docker-compose.prod.yml</p>
  </blockquote>
  <p>In my docker compose.yml i have my basic mysql stuff with dev als build target</p>
  <pre><code>version: &quot;3.4&quot;
  services:
    mysql:
      build:
        target: dev
      ...
  </code></pre>
  <p>And start it with</p>
  <blockquote>
  <p>docker-compose up -d</p>
  </blockquote>
  <p>In my staging environment i would like to expose port 3306, but also want another build target so i would create the docker-compose.staging.yml with the following content.</p>
  <pre><code>version: &quot;3.4&quot;
  services:
    mysql:
      build
        target: prod
      ports:
        - 3306:3306
  </code></pre>
  <p>And combine it with</p>
  <blockquote>
  <p>docker-compose -f docker-compose.yml -f docker-compose.staging.yml up -d</p>
  </blockquote>
  <p>So the build target is overwritten and the port 3306 is now exposed to the outside.</p>
  <p>Now i want the same in the docker-compose.prod.yml, just without having the port 3306 exposed to the outside ... How can i override the ports directive to not having ports exposed?</p>
  <p>I tried to put an empty array in the prod.yml without success (port is still exposed):</p>
  <pre><code>version: &quot;3.4&quot;
  services:
    mysql:
      ports: []
  </code></pre>
  <p>In the end i would like to stack the up command like this:</p>
  <blockquote>
  <p>docker-compose -f docker-compose.yml -f docker-compose.staging.yml -f docker-compose.prod.yml up -d</p>
  </blockquote>
  <p>I also know the docs says</p>
  <blockquote>
  <p>For the multi-value options ports, expose, external_links, dns, dns_search, and tmpfs, Compose concatenates both sets of values</p>
  </blockquote>
  <p>But how can i reach my goal anyway without duplicating configuration?</p>
  <p>Yes for sure, i could omit the docker-compose.staging.yml but in the staging.yml are build steps defined, which should also be used for the prod stage to not have any differences between the built container.
  So duplicating things isn't really an option.</p>
  <p>Thanks</p>