Description
Description
Starting with 2.37.0
, running the command docker compose up --build
in projects with an .env
directory fails with the following output:
> docker compose up --build
[+] Building 0.0s (1/1) FINISHED
=> [internal] load local bake definitions 0.0s
=> => reading from stdin 382B 0.0s
read /home/theor/tmp/docker-build-env-dir/.env: is a directory
Even though env_file
is explicitly specified in docker-compose.yml
:
services:
test:
build:
context: .
dockerfile: ./Dockerfile
env_file:
- .env/example
Using the --env-file
option makes no difference:
> docker compose --env-file .env/example up --build
[+] Building 0.0s (1/1) FINISHED
=> [internal] load local bake definitions 0.0s
=> => reading from stdin 382B 0.0s
read /home/theor/tmp/docker-build-env-dir/.env: is a directory
This is a regression from 2.36.2
, which didn't have this issue.
Steps To Reproduce
- Make sure you are running at least docker compose
2.37.0
. - Download minimal reproducible example: docker-build-env-dir-mre.zip.
- Unzip and
cd
to it. - Run
docker compose up --build
Compose Version
> docker compose version
Docker Compose version 2.37.1
> docker-compose version
Docker Compose version 2.37.1
Docker Environment
> docker info
Client:
Version: 28.2.2
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: 0.24.0
Path: /usr/lib/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: 2.37.1
Path: /usr/lib/docker/cli-plugins/docker-compose
Server:
Containers: 10
Running: 8
Paused: 0
Stopped: 2
Images: 773
Server Version: 28.2.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: true
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 splunk syslog
CDI spec directories:
/etc/cdi
/var/run/cdi
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 64ed272067a24c2d917064eea25a78e1479d632f.m
runc version:
init version: de40ad0
Security Options:
seccomp
Profile: builtin
rootless
cgroupns
Kernel Version: 6.15.2-arch1-1
Operating System: Arch Linux
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 62.59GiB
Name: theost
ID: 0c2346f7-0c51-4d23-8ce3-0eddc5dd56b3
Docker Root Dir: /home/theor/.local/share/docker
Debug Mode: false
Experimental: false
Insecure Registries:
::1/128
127.0.0.0/8
Live Restore Enabled: false
WARNING: No cpuset support
WARNING: No io.weight support
WARNING: No io.weight (per device) support
WARNING: No io.max (rbps) support
WARNING: No io.max (wbps) support
WARNING: No io.max (riops) support
WARNING: No io.max (wiops) support
Anything else?
This might be related to #10430, but in that instance it was failing regardless of using --build
, and --env-file
could be specified as a workaround.