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

long form syntax of ports directive doesn't support environment variable #35532

Closed
vzhgit opened this issue Nov 17, 2017 · 2 comments
Closed

Comments

@vzhgit
Copy link

vzhgit commented Nov 17, 2017

Description
environment variable doesn't set when uses the long form syntax of ports directive in a Compose file.

Steps to reproduce the issue:

  1. Create foo.yaml file
version: "3.2"
services:
 foo:
    image: nginx:1.13.0-alpine
    deploy:
      mode: global
    ports:
      - target: 80
        published: ${FOO_PORT}
        protocol: tcp
        mode: host
  1. Create foo.sh file
#!/bin/bash
export FOO_PORT=81
docker stack deploy -c foo.yaml bar
sleep 3
ip=$(ip route get 8.8.8.8 | awk '{print $NF; exit}')
curl http://$ip:$FOO_PORT
  1. run foo.sh

Describe the results you received:
services.foo.ports.0.published must be a integer

Describe the results you expected:

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

Additional information you deem important (e.g. issue happens only occasionally):
With a short syntax of ports directive it works perfect:

version: "3.2"
services:
 foo:
    image: nginx:1.13.0-alpine
    deploy:
      mode: global
    ports:
      - ${FOO_PORT}:80

Output of docker version:

Client:
 Version:      17.09.0-ce
 API version:  1.32
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:42:18 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.09.0-ce
 API version:  1.32 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   afdb6d4
 Built:        Tue Sep 26 22:40:56 2017
 OS/Arch:      linux/amd64
 Experimental: false

Output of docker info:

Containers: 8
 Running: 2
 Paused: 0
 Stopped: 6
Images: 63
Server Version: 17.09.0-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 121
 Dirperm1 Supported: 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 logentries splunk syslog
Swarm: active
 NodeID: 8jmlz14yu10b3zmsjdiii9ig8
 Is Manager: true
 ClusterID: xkmdf4v1ysftso4nrh09c15qo
 Managers: 1
 Nodes: 2
 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
 Autolock Managers: false
 Root Rotation In Progress: false
 Node Address: 192.168.101.128
 Manager Addresses:
  192.168.101.128:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-97-generic
Operating System: Ubuntu 16.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.945GiB
Name: ubuntu
ID: HSRD:2MUR:KJ5G:EMS7:IBLQ:C5ZV:KDLW:4VSZ:LRH6:77XL:6TTH:HEPI
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: mcctomsk
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support
@thaJeztah
Copy link
Member

Thanks for reporting, and the reproduction steps! This is a duplicate of docker/cli#229, and was resolved by docker/cli#601, which is part of Docker 17.11 and up.

I'll close this issue because it's been addressed, but feel free to continue the conversation, or if you're still able to reproduce on Docker 17.11 or up

@develar
Copy link

develar commented Nov 24, 2017

Version 17.11.0-ce-mac40 (20561)
Channel: edge
d8fd0f1f4a

IN:

ports:
      - target: 443
        published: ${NGINX_PORT:-8443}
        # disable routing mesh https://docs.docker.com/engine/swarm/ingress/#publish-a-port-for-a-service
        mode: host

OUT (NGINX_PORT=443 docker-compose -f docker-compose.yml -f docker-compose.prod.yml config > scripts/private/docker-compose.stack.yml):

ERROR: The Compose file './docker-compose.yml' is invalid because:
services.nginx.ports.published contains "443", which is an invalid type, it should be an integer

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

4 participants