在Azure容器实例的1个容器中运行的两个映像

时间:2020-03-18 14:23:22

标签: azure-container-instances azure-container-registry

我有两个图像上载到相同的Azure容器注册表和相同的存储库中。如何在同一容器中一起运行这两个映像。

预先感谢:)

当前,这是我的YAML代码。

apiVersion: 2018-10-01
location: eastus
name: web-mongo
properties:
  containers:
  - name: web
    properties:
      image: *.azurecr.io/phase1:1357
      resources:
        requests:
          cpu: 2
          memoryInGb: 10
      ports:
      - port: 80
  - name: mongo
    properties:
      image: *.azurecr.io/phase1:latest
      resources:
        requests:
          cpu: 2
          memoryInGb: 10
  osType: Linux
  ipAddress:
    type: Public
    ports:
    - protocol: tcp
      port: '80'
type: Microsoft.ContainerInstance/containerGroups
imageRegistryCredentials:
  - server: *.azurecr.io
    username: *
    password: ***


1 个答案:

答案 0 :(得分:0)

根据您的要求,可以使用YAML文件来实现它。我假设您将两个图像使用不同的标签上载到同一存储库中的ACR。然后,您可以像这样在一个容器组中一起运行两个映像:

apiVersion: 2018-10-01
location: eastus
name: myContainerGroup
properties:
  containers:
  - name: aci-tutorial-app
    properties:
      image: acr_name.azurecr.io/image_name:tag1
      resources:
        requests:
          cpu: 1
          memoryInGb: 1.5
      ports:
      - port: 80
      - port: 8080
  - name: aci-tutorial-sidecar
    properties:
      image: acr_name.azurecr.io/image_name:tag2
      resources:
        requests:
          cpu: 1
          memoryInGb: 1.5
  osType: Linux
  ipAddress:
    type: Public
    ports:
    - protocol: tcp
      port: '80'
    - protocol: tcp
      port: '8080'
tags: null
type: Microsoft.ContainerInstance/containerGroups
imageRegistryCredentials:
  - server: imageRegistryLoginServer
    username: imageRegistryUsername
    password: imageRegistryPassword

您可以获得有关Deploy a multi-container group using a YAML file的更多详细信息。 Azure Template也可以实现它。您可以根据需要选择一个。