cli: docker stack deploy does not allow variable substitution for replicas

Description

This is basically reopening https://github.com/moby/moby/issues/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:

  1. 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}
  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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 9
  • Comments: 15 (4 by maintainers)

Most upvoted comments

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

This is not resolved yet!

it is in 17.11.0-ce but I guess 17.11.0-ce is an edge release.

@ushuz thanks for reporting; unfortunately your comment got lost (as it was on a closed issue); I opened a new ticket instead https://github.com/docker/cli/issues/1073