简体   繁体   English

标记Docker映像并在docker-compose中添加变量

[英]Tagging docker images and adding variables in docker-compose

I'm using docker to build and deploy applications. 我正在使用Docker构建和部署应用程序。 After building the image i need to tag and use that image from another system which has docker-compose on it. 构建映像后,我需要标记并使用另一个具有docker-compose的系统的映像。 I'm using Jenkins to build and deploy images to private docker registries. 我正在使用Jenkins来构建映像并将其部署到私有docker注册表。 Docker compose file on the host system should automatically pull those images based on tag version. 主机系统上的Docker撰写文件应根据标签版本自动提取这些图像。

How to pass variables to docker-compose to substitute tag values ? 如何将变量传递给docker-compose以替换标签值?

Example: if a=2.4 then it should substitute 2.4 inside docker-compose file for a. 示例:如果a = 2.4,则应将docker-compose文件中的2.4替换为a。

version: '2'
services:
 web:
  image: httpd:$a
  ports:
    - 80:80

You can actually use this as written. 您实际上可以按书面使用。 Docker compose will use your OS environment to populate variables using the syntax that you have here. Docker compose将使用您的操作系统在OS环境中使用此处的语法填充变量。

On Mac/Linux: 在Mac / Linux上:

export a=2.4
docker-compose up

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM