I am working on a shared project, that contains a docker compose file with structure as below. (Confidential info removed)
version: "3.9"
# https://docs.docker.com/compose/compose-file/
x-common-variables: &common-variables
JAVA_TOOL_OPTIONS: -XX:MaxRAMPercentage=60.0 -Dlogging.level.com.backbase=DEBUG
... More common variables
x-database-variables: &database-variables
spring.liquibase.enabled: true
... More DB Variables
x-message-broker-variables: &message-broker-variables
spring.activemq.broker-url: tcp://message-broker:61616
... More message broker variables
x-healthcheck-defaults: &healthcheck-defaults
start_period: 60s
... more defaults
services:
mysql:
... More details
message-broker:
... More details
serviceName:
container_name: containerName
image: imagePath
ports:
- "8080:8080"
environment:
// Following line works
<<: *common-variables
another-service:
container_name: another-container
image: another-image-path
ports:
- "8040:8080"
environment:
<<: *common-variables
// BREAKS HERE
<<: *message-broker-variables
<<: *database-variables
The ingestion of variables via "<<" works for one service, but breaks for another with the following
line 138: mapping key "<<" already defined at line 137
I am using docker version
Docker version 24.0.2-rd, build e63f5fa
colima version 0.5.4
git commit: feef4176f56a7dea487d43689317a9d7fe9de27e
runtime: docker
arch: x86_64
client: v24.0.2-rd
server: v20.10.20
The same file works on other dev machines (I am not sure of their config). Kindly suggest what could be the cause of this issue?