docker / docker/cli

docker stack deploy does not allow variable substitution for networks

Open
#1,587 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/swarm platform/desktop
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Description

Steps to reproduce the issue:

  1. Create a docker-compose file using variable substitution for network
> cat docker-compose.yml
version: "3.7"
services:
  nc:
    image: alpine
    command: nc -lp1789
    ports:
      - "1789:1789"
    deploy:
      replicas: 3
    networks:
      - ${TEST_NETWORK}

networks:
  test_network:
  1. Stack deploy
docker stack deploy -c docker-compose.yml foo

Describe the results you received:

Creating network foo_
failed to create network foo_: Error response from daemon: rpc error: code = InvalidArgument desc = name must be valid as a DNS name component

Describe the results you expected:

Creating network foo_test_network
Creating service foo_nc

> docker service ls
ID                  NAME                           MODE                REPLICAS            IMAGE                                               PORTS
uoast75w85tp        foo_nc                         replicated          3/3                 alpine:latest                                       *:1789->1789/tcp

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

  • Checked for ${TEST_NETWORK} and $TEST_NETWORK
  • If service is deployed using docker-compose without stack, it works fine

Output of docker version:

Client: Docker Engine - Community
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:47:43 2018
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:55:00 2018
  OS/Arch:          linux/amd64
  Experimental:     true

Output of docker info:

Containers: 25
 Running: 20
 Paused: 0
 Stopped: 5
Images: 134
Server Version: 18.09.0
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 local logentries splunk syslog
Swarm: active
 NodeID: kl1m8rro9mx4v37cgemttsfk0
 Is Manager: true
 ClusterID: sljaq19fzji0q6btkxh77z3jf
 Managers: 1
 Nodes: 1
 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.65.3
 Manager Addresses:
  192.168.65.3:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 6
Total Memory: 7.786GiB
Name: linuxkit-025000000001
ID: STHX:ZGS4:QQXK:4M5A:5W4G:TDNQ:SVDU:GPND:GFCL:J6NO:NCZ5:2YMJ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 182
 Goroutines: 319
 System Time: 2018-12-19T16:55:08.933005909Z
 EventsListeners: 5
HTTP Proxy: gateway.docker.internal:3128
HTTPS Proxy: gateway.docker.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

Additional environment details (AWS, VirtualBox, physical, etc.):

  • physical system

Output of docker-compose config

networks:
  test_network: {}
services:
  nc:
    command: nc -lp1789
    deploy:
      replicas: 3
    image: alpine
    networks:
      test_network: null
    ports:
    - published: 1789
      target: 1789
version: '3.7'

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 example with docker-compose.yml and docker stack deploy, then compare the docker-compose config output with the stack deployment behavior. Done means the TEST_NETWORK substitution produces the expected foo_test_network and service deployment instead of the invalid foo_ network error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.