Overwrite items of YAML block (template) in docker-compose.yml

Hi, i have created a docker-compose.yml having reusable blocks:

services:
  sv1: &reuse
    build:
      args:
        PARAM1: "value of all sv"
        PARAM2: "value of all sv"
        PARAM3: "value of all sv"
    ...
  sv2:
    <<: *reuse
    build:
      args:
        PARAM2: "value of sv2"

My hope was that on the following blocks, only the value of PARAM2 will change, remaining all the former ones. But it looks like that this is not working this way?
Any ideas how to achieve this behaviour?

Hi,

To make parts of your YAML configuration reusable you need to use extends.

1 Like

So sorry! I mixed it up, it was a docker-compose.yml not a gitlab-ci.yml. I have changed it in my post above.

hmm, Iā€™m not so familiar with docker-compose.yml, sorry.