docker / docker/cli

docker stack config alters the final output, based on the order of compose files

Open
#4,549 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug status/0-triage
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Description

When giving multiple -c options to the docker stack config command, the order of the -c changes the final output

Reproduce

docker-compose.yml:

version: "3.5"

services:
  rabbitmq:
    hostname: rabbitmq
    image: rabbitmq:3.12.0-management
    ports:
      - "0:15672"
      - "0:5672"
    deploy:
      placement:
        constraints:
          - "node.role==manager"

docker-compose.override.yml

version: "3.5"
services:
  rabbitmq:
    labels:
      - "dk.cloudfactory.deployment.type=feature"

Below the outputs are different, based on the order of the options

 $ docker stack config -c docker-compose.yml -c docker-compose.override.yml
version: "3.5"
services:
  rabbitmq:
    deploy:
      placement:
        constraints:
        - node.role==manager
    hostname: rabbitmq
    image: rabbitmq:3.12.0-management
    labels:
      dk.cloudfactory.deployment.type: feature
    ports:
    - mode: ingress
      target: 5672
      protocol: tcp
$ docker stack config -c docker-compose.override.yml -c docker-compose.yml
version: "3.5"
services:
  rabbitmq:
    deploy:
      placement:
        constraints:
        - node.role==manager
    hostname: rabbitmq
    image: rabbitmq:3.12.0-management
    labels:
      dk.cloudfactory.deployment.type: feature
    ports:
    - mode: ingress
      target: 15672
      protocol: tcp
    - mode: ingress
      target: 5672
      protocol: tcp
Expected behavior

I expect that the order does not alter the final output, with the above examples

docker version
Client: Docker Engine - Community
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:51:00 2023
 OS/Arch:           linux/amd64
 Context:           alpha2

Server: Docker Engine - Community
 Engine:
  Version:          24.0.5
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.6
  Git commit:       a61e2b4
  Built:            Fri Jul 21 20:35:18 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.22
  GitCommit:        8165feabfdfe38c65b599c4993d227328c231fca
 runc:
  Version:          1.1.8
  GitCommit:        v1.1.8-0-g82f18fe
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
docker info
Client: Docker Engine - Community
 Version:    24.0.2
 Context:    default
 Debug Mode: false
 Plugins:
WARNING: Plugin "/usr/local/lib/docker/cli-plugins/docker-buildx" is not valid: failed to fetch metadata: fork/exec /usr/local/lib/docker/cli-plugins/docker-buildx: no such file or directory
WARNING: Plugin "/usr/local/lib/docker/cli-plugins/docker-compose" is not valid: failed to fetch metadata: fork/exec /usr/local/lib/docker/cli-plugins/docker-compose: no such file or directory
WARNING: Plugin "/usr/local/lib/docker/cli-plugins/docker-dev" is not valid: failed to fetch metadata: fork/exec /usr/local/lib/docker/cli-plugins/docker-dev: no such file or directory
WARNING: Plugin "/usr/local/lib/docker/cli-plugins/docker-extension" is not valid: failed to fetch metadata: fork/exec /usr/local/lib/docker/cli-plugins/docker-extension: no such file or directory
WARNING: Plugin "/usr/local/lib/docker/cli-plugins/docker-sbom" is not valid: failed to fetch metadata: fork/exec /usr/local/lib/docker/cli-plugins/docker-sbom: no such file or directory
WARNING: Plugin "/usr/local/lib/docker/cli-plugins/docker-scan" is not valid: failed to fetch metadata: fork/exec /usr/local/lib/docker/cli-plugins/docker-scan: no such file or directory

Server:
 Containers: 214
  Running: 62
  Paused: 0
  Stopped: 152
 Images: 112
 Server Version: 24.0.5
 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: active
  NodeID: porxiy0qzy7wq3rywpghgbdwa
  Is Manager: true
  ClusterID: f2hw0leixfxyttqootnobbehp
  Managers: 1
  Nodes: 2
  Default Address Pool: 10.0.0.0/8
  SubnetSize: 24
  Data Path Port: 4789
  Orchestration:
   Task History Retention Limit: 5
  Raft:
   Snapshot Interval: 10000
   Number of Old Snapshots to Retain: 0
   Heartbeat Tick: 1
   Election Tick: 10
  Dispatcher:
   Heartbeat Period: 5 seconds
  CA Configuration:
   Expiry Duration: 3 months
   Force Rotate: 0
  Autolock Managers: false
  Root Rotation In Progress: false
  Node Address: 10.245.110.202
  Manager Addresses:
   10.245.110.202:2377
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
 runc version: v1.1.8-0-g82f18fe
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.15.0-79-generic
 Operating System: Ubuntu 22.04.3 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 62.72GiB
 Name: CFDOC02
 ID: 5e474919-6dae-427d-84b8-347e901960ec
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
Additional Info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two docker stack config commands with docker-compose.yml and docker-compose.override.yml, then compare their final output. Trace the CLI's compose-file processing from the docker stack config entry point and determine why reversing -c options changes the ports. Done means both orders produce equivalent final output, with coverage for the reported files and commands.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.