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

docker compose fails if there is a folder called .env #1575

Closed
unikitty37 opened this issue Apr 20, 2021 · 1 comment · Fixed by compose-spec/compose-go#124
Closed

docker compose fails if there is a folder called .env #1575

unikitty37 opened this issue Apr 20, 2021 · 1 comment · Fixed by compose-spec/compose-go#124
Assignees
Labels
compatibility Compatibility with docker-compose

Comments

@unikitty37
Copy link

unikitty37 commented Apr 20, 2021

Description

When placing env files in a .env folder and specifying the relevant files using the env_file directive in docker-compose.yml, docker compose fails with the error read «path»/.env: is a directory whereas docker-compose works as expected.

As docker-compose never required .env to be a file, docker compose shouldn't either; it's perhaps sensible to default to looking there if there are no environment or env_file directives in docker-compose.yml, but I'd argue it makes more sense to require the env file to be specified explicitly in all cases.

It should certainly be possible to tell docker compose to not try and read a .env file, as this breaks existing setups.

Steps to reproduce the issue:

  1. Clone https://github.com/unikitty37/docker-compose-env-issue
  2. Type docker compose up -d

Describe the results you received:

This is what is output when running docker compose up -d. The container is not started.

The new 'docker compose' command is currently experimental. To provide feedback or request new features please open issues at https://github.com/docker/compose-cli
read /tmp/docker-compose-env-issue/.env: is a directory

Describe the results you expected:

This is what is output when running docker-compose up -d. The container is started.

Docker Compose is now in the Docker CLI, try `docker compose up`

Creating network "docker-compose-env-issue_default" with the default driver
Pulling container (ruby:3.0.1-alpine)...
3.0.1-alpine: Pulling from library/ruby
540db60ca938: Already exists
98a867505730: Already exists
69c77620f610: Already exists
637b90789817: Pull complete
b35a4d9a928a: Pull complete
Digest: sha256:944eae3da4a1fa4beb9796e62a9bdcac627800eb56dbc6f668dfb9b15e58719f
Status: Downloaded newer image for ruby:3.0.1-alpine
Creating docker-compose-env-issue_container_1 ... done

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

Output of docker version:

Client: Docker Engine - Community
 Cloud integration: 1.0.12
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:13:00 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:15:47 2021
  OS/Arch:          linux/amd64
  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)
  scan: Docker Scan (Docker Inc., v0.6.0)

Server:
 Containers: 11
  Running: 9
  Paused: 0
  Stopped: 2
 Images: 122
 Server Version: 20.10.5
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 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.runtime.v1.linux runc io.containerd.runc.v2
 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: x86_64
 CPUs: 12
 Total Memory: 4.821GiB
 Name: docker-desktop
 ID: 5CWG:A7VA:V3RE:4HKM:SUFD:PYI3:SEMM:BNIC:D6CN:ST6Q:MSYE:WIXM
 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.):

Running local on macOS 10.14.6 (18G8022).

@Strangerxxx
Copy link

It appears again on Docker Desktop 4.18.0 (104112)

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.

3 participants