dock-6ren">
gpt4 book ai didi

docker - .env 文件被 "sourced"忽略而不是 `docker-compose`

转载 作者:行者123 更新时间:2023-12-04 17:16:59 32 4
gpt4 key购买 nike

案例:我在docker-compose中启动了一个服务。.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."
...

环境:

  • Windows 10
  • Windows 版 Docker 桌面 3.5.2 (66501)
  • WSL 2
  • 编写 1.29.2

最佳答案

解决方案包括在“设置”>“实验性功能”中禁用使用 Docker Compose V2,然后“应用并重新启动”: enter image description here

警告:虽然此选项未选中,但 Docker 会在没有任何用户操作的情况下重新启用它。我在两台不同的笔记本电脑上多次遇到这种情况。

关于docker - .env 文件被 "sourced"忽略而不是 `docker-compose`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68504432/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com