Hello,
I’m running the docker compose installation on latest debian 11.
After upgrading docker-compose-plugin from 2.16.0 to 2.17.x, few errors popped up starting up the docker compose config:
yaml: unmarshal errors:
line 72: mapping key "<<" already defined at line 70
line 145: mapping key "image" already defined at line 139
line 150: mapping key "restart" already defined at line 140
line 217: mapping key "<<" already defined at line 215
I had to remove duplicate “image” and “restart” tags, and for the other lines I’ve followed this hint:
opened 03:46AM - 29 Mar 23 UTC
closed 06:39AM - 29 Mar 23 UTC
kind/bug
### Description
docker-compose.yml
```
version: '3.9'
# yml aliases and an… chors
x-mysql: &mysqlenv
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
MYSQL_USER: test
MYSQL_PASSWORD: test
x-mysql-extraenv: &mysqlextraenv
MY_CUSTOM_VAR: mycustomvalue
services:
mysql:
image: mysql:5.7
environment:
<<: *mysqlenv
<<: *mysqlextraenv
volumes:
- mysql-data:/var/lib/mysql
volumes:
mysql-data:
```
Try `docker-compose config`. Then getting the following error
```
yaml: unmarshal errors:
line 18: mapping key "<<" already defined at line 17
```
The version of my docker-compose is `2.17.2`
The same is working in `2.15.1` , `2.16.0` and even release candidate version `2.17.0-rc.1`.
This is broken from version `2.17.0`
<img width="466" alt="2023-03-29_09-13" src="https://user-images.githubusercontent.com/834529/228421352-a6ed33ad-2c69-4f48-a1f1-fa8f1ea69760.png">
### Steps To Reproduce
1. Windows 11
2. Docker compose v2.17.0
3. Copy the above docker-compose.yml
4. Then `docker-compose config`
5. You will see the error
### Compose Version
```Text
Docker Compose version v2.17.0
```
### Docker Environment
```Text
Client:
Context: default
Debug Mode: false
Server:
Containers: 9
Running: 1
Paused: 0
Stopped: 8
Images: 53
Server Version: 23.0.0
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 31aa4358a36870b21a992d3ad2bef29e1d693bec
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: builtin
cgroupns
Kernel Version: 5.15.0-67-generic
Operating System: Ubuntu 22.04 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 8.736GiB
Name: ubuntuserver2204
ID: c8839b3e-9c74-4cb6-9444-e5c979394be0
Docker Root Dir: /var/lib/docker
Debug Mode: false
Username: arulrajnet
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: API is accessible on http://0.0.0.0:2375 without encryption.
Access to the remote API is equivalent to root access on the host. Refer
to the 'Docker daemon attack surface' section in the documentation for
more information: https://docs.docker.com/go/attack-surface/
```
### Anything else?
**Not Working in 2.17.0**
```
arul@windows ~/Downloads/dc-yaml-alias-bug$~/Downloads/docker-compose-windows-x86_64-2.17.0.exe config
yaml: unmarshal errors:
line 18: mapping key "<<" already defined at line 17
```
**Working in 2.17.0-rc.1**
```
arul@windows ~/Downloads/dc-yaml-alias-bug$~/Downloads/docker-compose-windows-x86_64-2.17.0-rc.1.exe config
name: dc-yaml-alias-bug
services:
mysql:
environment:
MY_CUSTOM_VAR: mycustomvalue
MYSQL_DATABASE: test
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: test
image: mysql:5.7
networks:
default: null
volumes:
- type: volume
source: mysql-data
target: /var/lib/mysql
volume: {}
networks:
default:
name: dc-yaml-alias-bug_default
volumes:
mysql-data:
name: dc-yaml-alias-bug_mysql-data
x-mysql:
MYSQL_DATABASE: test
MYSQL_PASSWORD: test
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: test
x-mysql-extraenv:
MY_CUSTOM_VAR: mycustomvalue
```
the docker compose lines before:
<<: *mayan-container
<<: *mayan-frontend-ports
and after, this way it’s starting and working:
<<: [*mayan-container, *mayan-frontend-ports]
Hope this can help someone.
1 Like
Hi,
We encountered this recently while working on version 4.5. It took quite a while to figure out. This is independent confirmation that it is not a bug on our side.
I appreciate you taking the time to investigate this.
Thanks for the research and sharing your findings!