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

[BUG] [Regression] variables defined in custom env files not exported anymore #11509

Closed
remiville opened this issue Feb 16, 2024 · 2 comments
Closed
Assignees
Labels

Comments

@remiville
Copy link

Description

In compose 2.21.0 and earlier (I don't know in which version exactly the regression appeared) variables declared in custom env files were implicitelly exported (as variables defined in the .env file), i.e. you were not forced to write VAR_NAME=$VAR_NAME in the "env:" block of docker-compose.yaml
With compose 2.24.5 or 2.24.6 if you set VAR_NAME=value in a custom env file and declare env: - VAR_NAME (instead of env: -VAR_NAME=$VAR_NAME), the value of VAR_NAME will not be passed to the container.
With compose 2.21.0 the value of VAR_NAME is transmitted to the container without having to set again the value in the docker-compose.yaml file

Steps To Reproduce

Create a docker-compose.yaml with an include section

version: '3.7'
include:
  - path:
      - ./module/docker-compose.yaml
    env_file:
      - ./custom.env

In custom.env:

VAR_NAME=value

In ./module/docker-compose.yaml:

version: '3.7'
services:
  server:
    image: alpine
    entrypoint: printenv
    command: [VAR_NAME]
    environment:
      - VAR_NAME

Compose Version

Docker Compose version v2.24.6

Docker Environment

Client: Docker Engine - Community
 Version:    24.0.2
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.0-desktop.2
    Path:     /usr/local/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.6
    Path:     /usr/local/lib/docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.21
    Path:     /usr/local/lib/docker/cli-plugins/docker-extension
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  0.1
    Path:     /usr/local/lib/docker/cli-plugins/docker-feedback
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.10
    Path:     /usr/local/lib/docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-scan
  scout: Docker Scout (Docker Inc.)
    Version:  v1.2.0
    Path:     /usr/local/lib/docker/cli-plugins/docker-scout

Server:
 Containers: 4
  Running: 4
  Paused: 0
  Stopped: 0
 Images: 504
 Server Version: 24.0.7
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  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 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f
 runc version: v1.1.10-0-g18a0cb0
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
 Kernel Version: 5.10.102.1-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 5.794GiB
 Name: docker-desktop
 ID: 50c45cff-0652-41b6-8ba3-6a535b306730
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

@jhrotko
Copy link
Contributor

jhrotko commented Feb 22, 2024

@remiville the fix should be in the next compose release

@jhrotko jhrotko closed this as completed Feb 22, 2024
@milas
Copy link
Member

milas commented Mar 6, 2024

This fix has been included in Compose 2.24.7+. If you continue to have problems after upgrading, comment here and we can re-open the issue or create a new one as appropriate. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants