如何在Azure发布管道任务中向docker-compose.yml动态提供docker图像标签? [英] How to provide docker image tag dynamically to docker-compose.yml in Azure Release Pipeline Task?

本文介绍了如何在Azure发布管道任务中向docker-compose.yml动态提供docker图像标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存储库中存在 docker-compose.yml 文件.我已在其中一项服务中添加了image属性,以提取docker图像.我尚未对docker image和docker标签进行硬编码,并计划在运行时将这些参数传递给 docker-compose.yml 文件.

I have docker-compose.yml file present in the repository. I have added the image attribute in one of the services to pull the docker images. I have not hard coded the docker image and docker tag and planning to pass these arguments at the runtime to docker-compose.yml file.

如何将诸如 IMAGE_TAG = 82 IMAGE_NAME = app1 之类的运行时参数传递给 docker-compose.yml 文件?

How to pass the runtime arguments like IMAGE_TAG=82, IMAGE_NAME=app1 to the docker-compose.yml file?

推荐答案

您可以将docker-compose文件中的变量用于图片&标签:

You can use variables in the docker-compose file for the image & tag:

version: '3'
services:
    redis-server:
       image: ${IMAGE_NAME}:${IMAGE_TAG}

并在docker-compose任务中传递参数:

And pass the arguments in the docker-compose task:

您还可以定义管道变量并检查发布时的可设置表":

You can also define pipeline variables and check the "Settable at release time":

因此,当您单击创建发行版"时,您可以替换以下值:

So when you click on "Create Release" you can replace the values:

这篇关于如何在Azure发布管道任务中向docker-compose.yml动态提供docker图像标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆