简体   繁体   English

.env 文件被忽略,而不是由`docker-compose`“来源”

[英].env file is ignored and not “sourced” by `docker-compose`

Case: I start a service in docker-compose .案例:我在docker-compose启动了一个服务。 All the variables in the .env file are ignored and not dynamically replaced, such as below: .env文件中的所有变量.env被忽略,不会被动态替换,如下所示:

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:环境:

  • Windows 10视窗 10
  • Docker Desktop for Windows 3.5.2 (66501) Docker 桌面 Windows 3.5.2 (66501)
  • WSL 2 WSL 2
  • Compose 1.29.2撰写 1.29.2

The solution consists in disabling Use Docker Compose V2 in Settings > Experimental Features, then "Apply and Restart":解决方案包括在设置 > 实验功能中禁用Use Docker Compose V2 ,然后“应用并重新启动”: 在此处输入图片说明

Warning: although this option is unchecked, Docker happens to re-enable it without any user's action.警告:尽管未选中此选项,但 Docker 会在没有任何用户操作的情况下重新启用它。 This occurred to me several times, on two different laptops.我在两台不同的笔记本电脑上多次出现这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM