Incompatibility between docker-compose config and docker compose config outputs
Description
When generating configuration using config subcommand, docker compose config generates the name key whereas docker-compose config does not produce the name key
Steps to reproduce the issue:
- create a directory under
/tmpcalledtest-con - Create a simple
hello-worldcompose file calleddocker-compose.hello-world.ymlwithintest-con:
version: '3.7'
services:
hello:
image: hello-world:nano-server
container_name: hello_world
- use the
configcommand as follows:
docker compose -f docker-compose.hello-world.yml config
and use config for docker-compose
docker-compose -f docker-compose.hello-world.yml config
Describe the results you received:
docker compose -f docker-compose.hello-world.yml produces:
name: test-con
services:
hello:
container_name: hello_world
image: hello-world:nano-server
networks:
default: null
networks:
default:
name: test-con_default
whereas docker-compose -f docker-compose.hello-world.yml produces:
services:
hello:
container_name: hello_world
image: hello-world:nano-server
version: '3.7'
Describe the results you expected:
Either the YAML file should be same, or an option should be provided to suppress the name key value to make both the tools compatible and interoperable.
Additional information you deem important (e.g. issue happens only occasionally):
Output of docker compose version:
Docker Compose version 2.3.3
Output of docker info:
(paste your output here)
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.7.1-docker)
compose: Docker Compose (Docker Inc., 2.3.3)
Server:
Containers: 5
Running: 1
Paused: 0
Stopped: 4
Images: 15
Server Version: 20.10.12
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: false
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 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 10f428dac7cec44c864e1b830a4623af27a9fc70.m
runc version: v1.1.0-0-g067aaf85
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: default
cgroupns
Kernel Version: 5.10.105-1-MANJARO
Operating System: Manjaro Linux
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 30.65GiB
Name: shan-pc
ID: DEGH:RPQ4:ONO5:K27S:6T47:BDMJ:Y5RX:RQ3J:3D2R:VIUN:STZ6:WTOQ
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional environment details:
@shantanoo-desai Looks like everything works as expected on my end (compose v2.4.1)
Are you able to check with compose latest version ?
➜ docker compose version
Docker Compose version v2.4.1
➜ docker-compose version
Docker Compose version v2.4.1
➜ docker compose -f docker-compose.hello-world.yml config
name: test-con
services:
hello:
container_name: hello_world
image: hello-world:nano-server
networks:
default: null
networks:
default:
name: test-con_default
➜ docker-compose -f docker-compose.hello-world.yml config
name: test-con
services:
hello:
container_name: hello_world
image: hello-world:nano-server
networks:
default: null
networks:
default:
name: test-con_default
@maxcleme can confirm that with v2.4.1 the discrepancy is resolved.
Tests
with the same docker-compose.hello-world.yml file. I performed the following:
docker compose -f docker-compose.hello-world.yml config > cli.yml
as well as
docker-compose -f docker-compose.hello-world.yml config > std.yml
upon performing
diff std.yml cli.yml
the files were the same (no difference)