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

command option is not being overridden when using multiple compose files with docker stack deploy #1582

Open
mdawar opened this issue Dec 18, 2018 · 6 comments

Comments

@mdawar
Copy link

mdawar commented Dec 18, 2018

Description
I'm using multiple compose files for overriding service definitions for different environments, I noticed that when I try to override a service's command using another compose file it doesn't replace the original value but both values are used together.

Steps to reproduce the issue:

  1. Create a compose file with a service and set the command option to any value
  2. Create another compose file to override the command option in the first file
  3. Deploy the service using docker stack deploy -c docker-compose.yml -c docker-compose.dev.yml stack
  4. Check the service arguments using docker service inspect SERVICE_NAME -f '{{ .Spec.TaskTemplate.ContainerSpec.Args }}'

Example compose file:

version: '3.7'

services:

  service:
    image: busybox
    command: sh -c "while true; do echo $$HOSTNAME; sleep 2; done"

Another compose file to override the command option:

version: '3.7'

services:

  service:
    command: sh -c "while true; do echo $$HOME; sleep 2; done"

Describe the results you received:
Both command values are used together.

$ docker service inspect SERVICE_NAME -f '{{ .Spec.TaskTemplate.ContainerSpec.Args }}'
[sh -c while true; do echo $HOSTNAME; sleep 2; done sh -c while true; do echo $HOME; sleep 2; done]

Describe the results you expected:
We expect the command option to be overriden.

$ docker service inspect SERVICE_NAME -f '{{ .Spec.TaskTemplate.ContainerSpec.Args }}'
[sh -c while true; do echo $HOME; sleep 2; done]

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:           18.09.1-rc1
 API version:       1.39
 Go version:        go1.10.5
 Git commit:        bca0068
 Built:             Fri Dec  7 05:30:33 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.1-rc1
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.5
  Git commit:       bca0068
  Built:            Fri Dec  7 04:59:10 2018
  OS/Arch:          linux/amd64
  Experimental:     false

Output of docker info:

Containers: 3
 Running: 0
 Paused: 0
 Stopped: 3
Images: 121
Server Version: 18.09.1-rc1
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: active
 NodeID: ysu1ke2vx275m5tzbh83pl4op
 Is Manager: true
 ClusterID: 7nuqacmpewluzeb2zhe8v3oeo
 Managers: 1
 Nodes: 3
 Default Address Pool: 10.0.0.0/8  
 SubnetSize: 24
 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: 192.168.99.1
 Manager Addresses:
  192.168.99.1:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: de1f167ab96338a9f5c2b17347abf84bdf1dd411
runc version: 10d38b660a77168360df3522881e2dc2be5056bd
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.0-8-amd64
Operating System: Debian GNU/Linux 9 (stretch)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.762GiB
Name: debian
ID: NW3S:FKHM:UGZW:ZXF7:IFXW:7D7O:TVBJ:WXNE:7T34:2SVL:JVIV:SWZO
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: mdawar
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.):
Tested on Docker CE versions 18.09.1-rc1 and 18.06.1 on both Debian 9 and VirtualBox (boot2docker) using docker-machine.

@mdawar mdawar changed the title command is not being overridden when using multiple compose files with docker stack deploy command is not replaced when using multiple compose files with docker stack deploy Dec 18, 2018
@mdawar mdawar changed the title command is not replaced when using multiple compose files with docker stack deploy command is not being overridden when using multiple compose files with docker stack deploy Dec 18, 2018
@mdawar mdawar changed the title command is not being overridden when using multiple compose files with docker stack deploy command option is not being overridden when using multiple compose files with docker stack deploy Dec 18, 2018
@ferrym4n
Copy link

ferrym4n commented Oct 9, 2019

Ran into this same problem just now with version 19.03.2.

Output of docker version:

Client: Docker Engine - Community
 Version:           19.03.2
 API version:       1.40
 Go version:        go1.12.8
 Git commit:        6a30dfc
 Built:             Thu Aug 29 05:28:55 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.2
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.8
  Git commit:       6a30dfc
  Built:            Thu Aug 29 05:27:34 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

@harrier-lcc
Copy link

having the same issue in latest docker.

a.yaml, b.yaml:

version: '3.7'
services:
  test:
    image: busybox
    command: sh

After running docker stack deploy -c a.yaml -c b.yaml test then docker ps --all:

f72e21d2dfc5        busybox:latest                                                                                                                           "sh sh"                  8 seconds ago       Exited (2) Less than a second ago                       test_test.1.vgvgd8ajb8lz17bycp52nuyip

It executed sh sh instead of sh.

Output of docker version:

Client: Docker Engine - Community
 Version:           19.03.4
 API version:       1.40
 Go version:        go1.12.10
 Git commit:        9013bf583a
 Built:             Fri Oct 18 15:54:09 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.4
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.10
  Git commit:       9013bf583a
  Built:            Fri Oct 18 15:52:40 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

@carlfischerjba
Copy link

Same here. I also tried providing the command as an array and as a list but it didn't help.

@carlfischerjba
Copy link

A workaround suggested in #1651 is to create a combined compose file with docker-compose before passing it to docker stack deploy.

docker-compose -f docker-compose.yml -f docker-compose.prod.yml config > docker-compose.full.yml
docker stack deploy docker-compose.full.yml test

Or alternatively pipe it directly.

docker-compose -f docker-compose.yml -f docker-compose.prod.yml config | docker stack deploy -c - test

@douardda
Copy link

This is almost 2 years old, any chance to get any news? The documentation explicitly state that for "command" the expected behavior is to override the previous value, which "docker deploy" does not. Thanks

@ndeloof
Copy link
Contributor

ndeloof commented Jun 14, 2021

This has been fixed in compose-go: compose-spec/compose-go#133
Unfortunately docker stack does not support the compose-specification. See #2527

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

No branches or pull requests

8 participants