Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Network aliases from multiple docker-compose files do not get merged #9981

Closed
noraab opened this issue Nov 7, 2022 · 6 comments · Fixed by compose-spec/compose-go#323
Assignees
Labels

Comments

@noraab
Copy link

noraab commented Nov 7, 2022

Description

I have network aliases for the same service in multiple docker-compose files; In docker-compose (v1) all aliases get merged, in docker compose (v2) only the aliases from additional files are applied.

Steps To Reproduce

docker-compose.yml

version: "3"
services:
  s1:
    image: busybox
    networks:
      default:
        aliases:
          - alias1
    command: ["sleep", "1h"]

  s2:
    image: busybox
    command: ["ping", "alias1"]

docker-compose.override.yml

version: "3"
services:
  s1:
    networks:
      default:
        aliases:
          - alias2

Run docker-compose config with version 1.29.2

services:
  s1:
    command:
    - sleep
    - 1h
    image: busybox
    networks:
      default:
        aliases:
        - alias1
        - alias2
  s2:
    command:
    - ping
    - alias1
    image: busybox
version: '3'

Run docker compose config with version v2.12.2

name: test
services:
  s1:
    command:
    - sleep
    - 1h
    image: busybox
    networks:
      default:
        aliases:
        - alias2
  s2:
    command:
    - ping
    - alias1
    image: busybox
    networks:
      default: null
networks:
  default:
    name: test_default

Compose Version

$ docker compose version
Docker Compose version v2.12.2

$ docker-compose version
docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l  10 Sep 2019

Docker Environment

$ docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
  compose: Docker Compose (Docker Inc., v2.12.2)
  scan: Docker Scan (Docker Inc., v0.21.0)

Server:
 Containers: 2
  Running: 0
  Paused: 0
  Stopped: 2
 Images: 36
 Server Version: 20.10.21
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 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: 1c90a442489720eec95342e1789ee8a5e1b9536f
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.102.1-microsoft-standard-WSL2
 Operating System: Ubuntu 20.04 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 24.12GiB
 Name: x
 ID: ADI4:WORP:NW7D:5Z5Y:ULNP:TWEA:LSBA:5GDV:G44E:7LCM:SIK3:RBBM
 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

Anything else?

Basically, this is a new issue for a problem, that has been closed without beeing fixed. See #8719

@ndeloof
Copy link
Contributor

ndeloof commented Nov 30, 2022

Need to remove https://github.com/compose-spec/compose-go/blob/master/loader/merge.go#L333
Not sure why we get this line, this code is inherited from swarm support introduced in docker/cli, maybe just a mistake

@ndeloof
Copy link
Contributor

ndeloof commented Nov 30, 2022

an explicit test case has been included in compose-go to confirm this (wrong?) expectation. I'll dig into code history to better understand this decision

@strozl
Copy link

strozl commented Dec 15, 2022

I also have this issue. when it will be resolved?

@ndeloof
Copy link
Contributor

ndeloof commented Dec 15, 2022

The whole merge logic has been introduced at once by docker/cli@1872bd8#diff-3656731ab09fddb23d9fe7c01e366ecd80e82d8dce9720f90583a887064f18b9, which makes it hard to understand the reason this special handling for aliases was introduced.

Considering this behavior is not implemented by Compose v1, I guess we can assume we should better adopt backward compatibility, and investigate ability for an override file to unset values (compose-spec/compose-spec#284)

ndeloof added a commit to compose-spec/compose-go that referenced this issue Dec 19, 2022
@noraab
Copy link
Author

noraab commented Dec 19, 2022

Hi @ndeloof,
thank you very much for providing a fix. I'm sorry to ask, but in which version will the fix be released? I can't find the specific info anywhere.

@ndeloof
Copy link
Contributor

ndeloof commented Dec 19, 2022

not released yet. Probably in next release v2.14.2. Check the changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants