Repository navigation
docker stack deploy does not allow variable substitution for replicas #229
Copy link
Copy link
Closed
Milestone
Description
Description
This is basically reopening moby/moby#32118
I'd like to use some variable substitutions in my docker-compose.yml to define how my stack should be deployed. However, some keys must be of a certain type, for instance integers.
Steps to reproduce the issue:
- Create a docker-compose file using variable substitution for port and replicas
> cat demo.yml
version: "3.3"
services:
nc:
image: alpine
command: nc -lp1789
ports:
- "1789:1789"
deploy:
replicas: ${NC_REPLICAS:-1}
- Stack Deploy
> docker stack deploy --compose-file demo.yml foo
Describe the results you received:
> docker stack deploy --compose-file demo.yml foo
services.nc.deploy.replicas must be a integer
Describe the results you expected:
sdf
> NC_REPLICAS=2 docker stack deploy --compose-file demo.yml foo
service created
> docker service ls
ID NAME MODE REPLICAS IMAGE
X foo_nc replicated 2/2 nc
Additional information you deem important (e.g. issue happens only occasionally):
Output of docker version:
Client:
Version: 17.06.0-ce-rc5
API version: 1.30
Go version: go1.8.3
Git commit: b7e4173
Built: Tue Jun 20 07:14:13 2017
OS/Arch: darwin/amd64
Server:
Version: 17.06.0-ce-rc5
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: b7e4173
Built: Tue Jun 20 07:18:21 2017
OS/Arch: linux/amd64
Experimental: true
Output of docker info:
Containers: 89
Running: 31
Paused: 0
Stopped: 58
Images: 282
Server Version: 17.06.0-ce-rc5
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 ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
NodeID: lvf5hvwinjbcoujab7jzw0tss
Is Manager: true
ClusterID: 7m5abn45bpvmdrp2ntqbayhm9
Managers: 1
Nodes: 1
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 3
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Root Rotation In Progress: false
Node Address: 192.168.65.2
Manager Addresses:
192.168.65.2:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.31-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 2.933GiB
Name: moby
ID: DQ7K:NL44:CJT3:YYUR:M6TL:DSE4:ZIVL:DMY7:CJ4I:UVMQ:LDSB:U4HS
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 325
Goroutines: 431
System Time: 2017-06-21T20:36:14.592817654Z
EventsListeners: 10
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional environment details (AWS, VirtualBox, physical, etc.):
N/A
Reacted by puncha, Jake Scaltreto, Stephen Lacy, Ivan Boyko, Ricardo Rover, Zlatoslav Desyatnikov, Alexandre Ferreira, Yang Mei Lin and Roman Morokhovsky
Activity
bitsofinfo commentedon Nov 30, 2017
any ideas on when this will be available in a mainstream release?
seriousben commentedon Nov 30, 2017
it is in 17.11.0-ce but I guess 17.11.0-ce is an edge release.
DBLaci commentedon Nov 30, 2017
I confirm 17.11 works with replica: "2" ( i did not tested earlier as I did not know about the progress)
ushuz commentedon Apr 13, 2018
Seems there's a regression in 18.04.0-ce, as I'm experiencing the issue in the latest boot2docker image.
thaJeztah commentedon May 22, 2018
@ushuz thanks for reporting; unfortunately your comment got lost (as it was on a closed issue); I opened a new ticket instead #1073
fpoulinSpiria commentedon Apr 17, 2019
Still having the same problem with docker-compose 3.7.
If like me you are trying to manage scaling by environment through env variables, I didn't find any solution except docker-compose.overrides or 'sed' script to replace the variable before docker stack deploy
brunocascio commentedon May 8, 2020
I'm facing the same with 3.7 version:
SayidHosseini commentedon Jul 5, 2020
This is not resolved yet!
lrayman commentedon Sep 22, 2020
I am suffering from the same issue 😢
sample from compose file:
thaJeztah commentedon Sep 23, 2020
@fpoulinSpiria @brunocascio @SayidHosseini @lrayman
I'm not able to reproduce the problem on a current version of Docker (19.03.13)
Steps I took to reproduce (note that I tried both
version: "3.8"andversion: "3.0"and both worked@lrayman Docker version 1.13.x is really old, and reached EOL over three Years ago. I suspect you're running the Red Hat fork of Docker, not the official packages (https://docs.docker.com/engine/install/). While there's currently no packages for RHEL specific, you should be able to install the CentOS packages. If you're not able to use the official Docker packages, I'd recommend opening a support ticket with Red Hat support.
brunocascio commentedon Sep 23, 2020
Hey @thaJeztah,
Using ansible to inject vars you have to quote them, for example:
thaJeztah commentedon Sep 24, 2020
Yes, if there's quotes around it, it will still produce an error;
That looks like a separate issue; feel free to open a new ticket for that for discussion
SayidHosseini commentedon Oct 11, 2020
@thaJeztah you are right!
The issue seems to have been resolved.
Thanks.
GuillaumePoignon commentedon Jun 24, 2022
With docker-compose 2.6.0 I can't set
deploy.replicaswith env varservices.mqtt_receiver.display.deploy.replicas must be a integerthaJeztah commentedon Jun 24, 2022
@GuillaumePoignon could you open a ticket in the docker compose issue tracker for that? https://github.com/docker/compose/issues
Merge pull request docker#229 from andrewhsu/static