停靠-组合.yaml
version: "3"
services:
Database:
image: postgres
container_name: Database
restart: always
ports:
- "${DATA_BASE_HOST}:${DATA_BASE_HOST}"
env_file:
- 01-Source/Infrastructure/Interactions/ClientAndFrontServer/.env.dataBase.local.public
- 01-Source/Infrastructure/Interactions/ClientAndFrontServer/.env.dataBase.local.private
// ...
我确保文件的路径是正确的。如果在这些路径中出错,错误如下
open D:\IntelliJ IDEA\XXX\01-Source\Infrastructure\Interactions\ClientAndFrontServe
r\.env.dataBase.local.publicd:
The system cannot find the file specified.
`docker-compose` process finished with exit code 14
将发生。
.环境.数据库.本地.公共
DATA_BASE_HOST=localhost
DATA_BASE_PORT=5432
错误
Ttime="2022-10-23T10:51:41+09:00" level=warning msg="The \"DATA_BASE_HOST\" variable is not set. Defaulting to a blank st
ring."
1 error(s) decoding:
* error decoding 'Ports': No port specified: :<empty>
`docker-compose` process finished with exit code 15
1条答案
按热度按时间guz6ccqo1#
env_file
指令在容器 * 内部 * 设置环境变量,并且不影响docker合成。要设置可在docker合成中使用的环境变量,可以将文件命名为
.env
,也可以在docker合成命令中使用--env-file
选项要使用数据库文件,您需要执行以下操作
更多信息,请访问:https://docs.docker.com/compose/environment-variables/#using-the---env-file--option