Skip to content

--env-file option messes up .env path when stopping app in Desktop #6229

Closed
docker/compose
#9422
@plueschpruem

Description

@plueschpruem

I posted this here already, but it seems the bug is on the Desktop App side…

I am building a workflow to use a single docker-compose.yml to manage several similar projects.
I want to solve that with several .env files to use with the --env-file shell option:
docker-compose --env-file ./Docker_Config/env_files/test1.env -f ./Docker_Config/docker-compose.yml --project-name test1 up -d --build
Inside the test1.env is this:
DOCKER_NAME=test1

File structure:
root
— Docker_Config
—— env_files
——— test1.env
—— docker-compose.yml

This works as expected, the app builds, starts, all containers are correctly named via the variabel – so far so dandy.
But when I try to stop the app (with the STOP button in Docker Desktop / Apps), I get an error that Docker Desktop could not find the test1.env file.
It seems that Docker is always prepending the full folder of the docker-compose.yml to the .env.
So in my case it tries to open the file at […]Docker_Config/Docker_Config/env_files/test1.env
To confirm I also moved my .yml a level further into another folder – that then also got prepended.
So basically the ONLY possibility to use this new (and frankly very useful) option is to keep all your docker-compose.yml and .env files in the root level. But I guess this is an error, not the desired functionality?

The shell command down works – it lists all containers and takes them down one by one.
The button DELETE (trashcan) works in the Desktop App. Only STOP fails for me.

Additionally the app console echos some of these on startup:
time="2022-03-12T19:19:25+01:00" level=warning msg="The \"DOCKER_NAME\" variable is not set. Defaulting to a blank string."
Guess that could be connected? Because I only used that var in the docker-config.yml, not in the app itself. It is never passed to the containers and all the functionality the var does provide to the docker-config.yml is working as expectd.

Screenshot of the error:
Bildschirmfoto 2022-03-12 um 20 13 49

  • I have tried with the latest version of Docker Desktop
  • I have tried disabling enabled experimental features
  • I have uploaded Diagnostics
  • Diagnostics ID:

Expected behavior

Use the provided .env file passed by the --env-file option

Actual behavior

Prepends the docker-compose.yml folder path to the .env and thus fails.

Information

  • macOS Version: 12.2.1 (21D62)
  • Intel chip or Apple chip: Intel
  • Docker Desktop Version: 4.5.0 (74594)
  • Docker version 20.10.12, build e91ed57
  • Docker Compose version v2.2.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions