Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

docker compose run/exec does not pass env variables without value (docker-compose does) #1681

Closed
vitalets opened this issue May 18, 2021 · 7 comments · Fixed by #1682
Closed
Assignees
Labels
compatibility Compatibility with docker-compose

Comments

@vitalets
Copy link

Description
To pass env variable from current environment as is in docker-compose I can set -e VAR without specifying value.
It does not work in new docker compose cli.

Steps to reproduce the issue:

  1. Cerate docker-compose.yml:
version: '3.8'
services:
  nginx:
    image: nginx
  1. Run container with passing env variable from current env:
VAR=foo docker compose run --rm -e VAR nginx sh -c 'echo $VAR'

Describe the results you received:
Nothing printed.

Describe the results you expected:
foo printed.

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

  1. If running with docker-compoer VAR is passed and printed:
VAR=foo docker-compose run --rm -e VAR nginx sh -c 'echo $VAR'
> foo
  1. The same behavior is with docker compose exec.

Output of docker version:

Client:
 Cloud integration: 1.0.14
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.16.3
 Git commit:        370c289
 Built:             Fri Apr  9 22:46:57 2021
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:44:13 2021
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker context show:
You can also run docker context inspect context-name to give us more details but don't forget to remove sensitive content.

default

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  compose: Docker Compose (Docker Inc., 2.0.0-beta.1)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 4
  Running: 0
  Paused: 0
  Stopped: 4
 Images: 44
 Server Version: 20.10.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.25-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 4
 Total Memory: 1.942GiB
 Name: docker-desktop
 ID: 773E:2ELA:XLQL:EDUS:OOJM:3QBL:NATZ:W7ZJ:V35U:EBVT:MS2A:IQM3
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS ECS, Azure ACI, local, etc.):

@ndeloof
Copy link
Collaborator

ndeloof commented May 18, 2021

This has been fixed already in 1.0.15 release

You can confirm by downloading binaries from release page, get docker-compose from the distribution tar.gz and move it into your ~/.docker/cli-plugins folder. Check correct installation by docker compose version => 2.0.0-beta.2

@vitalets
Copy link
Author

This has been fixed already in 1.0.15 release

You can confirm by downloading binaries from release page, get docker-compose from the distribution tar.gz and move it into your ~/.docker/cli-plugins folder. Check correct installation by docker compose version => 2.0.0-beta.2

Thanks! Didn't find such issue. When approximately 1.0.15 is planned to release?

@ndeloof
Copy link
Collaborator

ndeloof commented May 18, 2021

@ndeloof ndeloof closed this as completed May 18, 2021
@vitalets
Copy link
Author

it is already -> https://github.com/docker/compose-cli/releases/tag/v1.0.15

I mean when it will be delivered with Docker desktop (without manually downloading tar.gz)?

@vitalets
Copy link
Author

@ndeloof
I've checked with 1.0.15. docker compose run works correctly, but docker compose exec does not.
Could you recheck?

VAR=foo docker compose run --rm -e VAR nginx sh -c 'echo $VAR'
> foo

VAR=foo docker compose exec -e VAR nginx sh -c 'echo $VAR'
> (empty line!)

VAR=foo docker-compose exec -e VAR nginx sh -c 'echo $VAR'
> foo

Version:

docker compose version
> Docker Compose version 2.0.0-beta.2

@ndeloof
Copy link
Collaborator

ndeloof commented May 18, 2021

right, I created #1682 to add support for exec
thanks for catching this!

@vitalets
Copy link
Author

right, I created #1682 to add support for exec
thanks for catching this!

Great! Thank you!

@ndeloof ndeloof self-assigned this May 20, 2021
@ndeloof ndeloof added compatibility Compatibility with docker-compose compose labels May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compatibility Compatibility with docker-compose
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants