[英]Use variables in docker-compose file image
I would like to pull and push my images to different repositories depending on the environment I am deploying them to. 我想根据将映像部署到的环境,将映像拉到不同的存储库中。
My .env file obviously only works in a single environment and currently i have to use multiple docker-compose files to get around this. 我的.env文件显然只能在单个环境中工作,当前我必须使用多个docker-compose文件来解决此问题。
Simply I would like to do something like this: 我只是想做这样的事情:
version: '2.1'
services:
my_service:
build:
dockerfile: Dockerfile.somedockerfile
image: ${docker_repo_host}:${docker_repo_port}/myimage:latest
Where I could pass in docker_repo_host
and docker_repo_port
dynamically when I am building. 构建时可以动态传递
docker_repo_host
和docker_repo_port
。 I am unsure if there is a way to do this neatly but any suggestion would be appreciated. 我不确定是否有办法巧妙地做到这一点,但是任何建议都会受到赞赏。
Export the two variables 导出两个变量
export docker_repo_host=your_host
export docker_repo_port=your_port
Now run the docker-compose command 现在运行docker-compose命令
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.