Skip to content

Docker stack command doesn't support required environment variables in compose file #1029

Description

@farmdawgnation

Description

Recent releases of Docker Compose have support for a required environment variable substitution using the syntax ${ENV_VAR?error message if missing}. (docs here)

So, for example, I should be able to do:

    environment:
      - "CLOUDFLARE_EMAIL=${CLOUDFLARE_EMAIL?cloudflare email}"
      - "CLOUDFLARE_API_KEY=${CLOUDFLARE_API_KEY?cloudflare api key}"

Indeed, docker-compose up appears to handle this correctly. However, when I attempt to use docker stack deploy I get:

invalid interpolation format for services.http.environment.[]: "CLOUDFLARE_EMAIL=${CLOUDFLARE_EMAIL?cloudflare email is required}". You may need to escape any $ with another $.

Steps to reproduce the issue:

  1. Write a compose file using the required environment variable syntax
  2. Attempt to use docker stack deploy with it
  3. 💥

Describe the results you received:

The Docker CLI' stack command fails to parse the compose file.

Describe the results you expected:

The Docker CLI's stack command should behave identically to docker-compose.

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

N/A

Output of docker version:

Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:13:02 2018
 OS/Arch:      darwin/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:22:38 2018
  OS/Arch:      linux/amd64
  Experimental: true

Output of docker info:

Containers: 14
 Running: 0
 Paused: 0
 Stopped: 14
Images: 69
Server Version: 18.03.1-ce
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: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.87-linuxkit-aufs
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.952GiB
Name: linuxkit-025000000001
ID: JQ4U:ATEE:MKJ5:NQXB:HMHL:GCNR:RYQA:E7IZ:X7S4:WHS4:TOPI:NITE
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 21
 Goroutines: 39
 System Time: 2018-04-29T15:16:31.63891038Z
 EventsListeners: 2
HTTP Proxy: docker.for.mac.http.internal:3128
HTTPS Proxy: docker.for.mac.http.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

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

N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions