command option is not being overridden when using multiple compose files with docker stack deploy
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6.1k
- Forks
- 2.2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 43
Description
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:
- Create a compose file with a service and set the
commandoption to any value - Create another compose file to override the
commandoption in the first file - Deploy the service using
docker stack deploy -c docker-compose.yml -c docker-compose.dev.yml stack - 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the docker stack deploy entry point and how it processes the two -c compose files, then trace merging of the service command option. Reproduce with the provided compose files and verify with docker service inspect that only the overriding command appears in the service arguments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, go
- Domain
- cli, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100