Skip to content

Regression in handling of environment variables #9492

@camilledejoye

Description

@camilledejoye

BUG REPORT INFORMATION

Description

From the documentation:

Values in the shell take precedence over those specified in the .env file.

This is no longer true since the 2.5.1 release.

Steps to reproduce the issue:

  1. Create a docker-compose.yaml file with:
services:
  alpine:
    image: alpine:latest
    environment:
      - MY_VAR
  1. Create a .env file with:
MY_VAR=file
  1. Run MY_VAR=shell docker compose run alpine printenv MY_VAR

Describe the results you received:

Current output: file

Describe the results you expected:

Expected output: shell

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

Works on Docker Compose 2.5.0.

Output of docker compose version:

Docker Compose version 2.5.1

Output of docker version:

Client:
 Version:           20.10.16
 API version:       1.41
 Go version:        go1.18.1
 Git commit:        aa7e414fdc
 Built:             Sat May 14 12:48:33 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.16
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.1
  Git commit:       f756502055
  Built:            Sat May 14 12:47:27 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.6.4
  GitCommit:        212e8b6fa2f44b9c21b2798135fc6fb7c53efc16.m
 runc:
  Version:          1.1.2
  GitCommit:
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
  compose: Docker Compose (Docker Inc., 2.5.0)

Server:
 Containers: 186
  Running: 12
  Paused: 0
  Stopped: 174
 Images: 22
 Server Version: 20.10.16
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 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: 212e8b6fa2f44b9c21b2798135fc6fb7c53efc16.m
 runc version:
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.17.9-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.57GiB
 Name: cdejoye-arch
 ID: YFDR:NZWH:MQ5W:LNXA:3F47:VZMQ:7MPC:MUKR:4LT6:SUFM:TRTW:BTFN
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions