[英]docker-compose - env vars based on the ports
So I have 2 services running - my website and the API. 因此,我有2个服务正在运行-我的网站和API。
In my code for the website I specified that it should use the API that has port
equal to API_PORT
env var. 在我的网站代码中,我指定它应该使用port
等于API_PORT
env var的API。
My question: is there a way to set the API_PORT
variables based on the ports from api service? 我的问题:有没有一种方法可以根据api服务的端口设置API_PORT
变量?
Overview of my docker-compose.yml
: 我docker-compose.yml
概述:
api-service:
...otherconfig
ports:
- 8009:8009
website:
...
Just inject the API_PORT
env var into your compose file too: 只需将API_PORT
env var注入到您的撰写文件中:
export API_PORT=8009
then in the compose file 然后在撰写文件中
api-service:
...otherconfig
ports:
- ${API_PORT}:${API_PORT}
website:
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.