将参数传递给 docker compose [英] Pass argument to docker compose
本文介绍了将参数传递给 docker compose的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 docker compose 文件中有一个我想在运行期间生成的动态字段.实际上它是一个字符串模板:
In my docker compose file there is a dynamic field which I'd like to generate during the running. Actually it is a string template:
environment:
- SERVER_URL:https://0.0.0.0:${PORT}
我想动态配置这个PORT
参数
docker-compose run <service> PORT=443
在 documentation 中有 ARGS
参数集我假设我可以使用.但是没有信息如何使用撰写文件中的那些
In documentation there is ARGS
parameters set I suppose I can use. But there is no information how can I use those inside compose file
推荐答案
这可以通过 stack deploy
您的环境部分中的 Compose 文件示例:
Example Compose File in your environment section:
- MY_VARIABLE_NAME=${MY_VARIABLE_VALUE}
Stack Deploy 命令(我在 Windows 中从 Gitbash 运行此命令):
Stack Deploy Command (I ran this from Gitbash in Windows):
MY_VARIABLE_VALUE=some-value docker stack deploy --compose-file compose_file_here stackname
参考资料在此处
这篇关于将参数传递给 docker compose的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文