Jonathan Lalou
Jonathan Lalou

Reputation: 324

.env file is ignored and not "sourced" by `docker-compose`

Case: I start a service in docker-compose. All the variables in the .env file are ignored and not dynamically replaced, such as below:

PS C:\workarea\jonathan\myProject> docker-compose up -d myService
time="2021-07-23T15:20:50-04:00" level=warning msg="The XXXXX_URL variable is not set. Defaulting to a blank string."
time="2021-07-23T15:20:50-04:00" level=warning msg="The XXXXX_USER variable is not set. Defaulting to a blank string."
time="2021-07-23T15:20:50-04:00" level=warning msg="The XXXXX_PASSWORD variable is not set. Defaulting to a blank string."
time="2021-07-23T15:20:50-04:00" level=warning msg="The YYYY_URL variable is not set. Defaulting to a blank string."
time="2021-07-23T15:20:50-04:00" level=warning msg="The ZZZ_URL variable is not set. Defaulting to a blank string."
time="2021-07-23T15:20:50-04:00" level=warning msg="The XXXXX_URL variable is not set. Defaulting to a blank string."
time="2021-07-23T15:20:50-04:00" level=warning msg="The XXXXX_USER variable is not set. Defaulting to a blank string."
time="2021-07-23T15:20:50-04:00" level=warning msg="The XXXXX_PASSWORD variable is not set. Defaulting to a blank string."
time="2021-07-23T15:20:50-04:00" level=warning msg="The YYYY_URL variable is not set. Defaulting to a blank string."
time="2021-07-23T15:20:50-04:00" level=warning msg="The ZZZ_URL variable is not set. Defaulting to a blank string."
time="2021-07-23T15:20:50-04:00" level=warning msg="The DDDDD_ROOT_PASSWORD variable is not set. Defaulting to a blank string."
...

Environment:

Upvotes: 3

Views: 1264

Answers (1)

Jonathan Lalou
Jonathan Lalou

Reputation: 324

The solution consists in disabling Use Docker Compose V2 in Settings > Experimental Features, then "Apply and Restart": enter image description here

Warning: although this option is unchecked, Docker happens to re-enable it without any user's action. This occurred to me several times, on two different laptops.

Upvotes: 1

Related Questions