将映像从Azure容器注册表部署到Azure Linux虚拟机 [英] Deploy image from Azure Container Registry to an Azure Linux Virtual Machine
问题描述
我创建了一个构建管道,用于构建基于docker的项目.该图像将被推送到Azure容器注册表.
I have created a build-pipeline which builds my docker based project. The image is being pushed to the Azure Container Registry.
我想要实现的是将映像部署到虚拟机,但是我不知道从哪里开始.例如,是否需要创建一个释放管道来在虚拟机上执行脚本,从而导致映像被拉出并运行?
What I want to achieve is to deploy the image to a virtual machine but I have no idea where to start. Do I for example need to create a release pipeline which executes a script on the virtual machine which results in the image being pulled and run?
希望有人可以帮助我解决这个问题.
Hope some can help me out with this one.
推荐答案
如果要自动化该过程以通过Azure管道将映像部署到虚拟机.您需要创建管道,或将执行虚拟机上的停靠命令的其他代理作业或步骤添加到现有管道.请查看以下可能的解决方法:
If you want to automate the process to deploy the image to a virtual machine via azure pipeline. You need to create a pipeline, or add an additional agent job or step which executes the dock commands on the virtual machine to your existing pipeline. Check out below possible workarounds:
1,在虚拟机上创建一个自托管代理.请参见此处>详细步骤.
1, Create a self-hosted agent on the virtual machine. See tutorial here for detailed steps.
然后,您可以添加其他代理作业或创建发布管道以在脚本任务中运行docker命令.并配置代理程序池以在自托管代理程序池上运行作业.
Then you can add an additional agent job or create a release pipeline to run the docker commands in a script task. And configure the agent pool to run the job on your self-hosted agent pool.
对于以下示例.我添加了一个额外的作业,并在powershell任务中执行了docker命令来运行映像:
For below example. I add an additional job and execute the docker commands in a powershell task to run the image:
stages:
- stage:
jobs:
- job: Build
steps:
...
- job: Deploy
dependsOn: Build
pool: Default #run this job on the self-hosted agent which is hosted on the VM.
steps:
- powershell: |
docker login CONTAINERREGISTRYURL -u CONTAINERREGISTRYNAME -p CONTAINERREGISTRYPASSWORD
docker run ....
2,如果您不想创建自托管代理.您还可以尝试在管道中使用以下任务之一,该任务使您可以在目标虚拟机上运行停靠脚本.
2, If you donot want to create a self hosted agent. You can also try using one of below tasks in your pipeline, which allow you run the dock scripts on the target Virtual machine.
这篇关于将映像从Azure容器注册表部署到Azure Linux虚拟机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!