0

I have two images uploaded into the same Azure Container Registry and the same repoistory. How do I run these two images together in a same container.

Thanks in advance :)

Currently this is my YAML code.

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: ***


Evelyn Omo
  • 89
  • 1
  • 4

1 Answers1

0

For your requirements, you can use the YAML file to achieve it. I assume you upload the two images to the ACR in the same repository with different tags. Then you can run the two images together in the only one container group like this:

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

You can get more details about Deploy a multi-container group using a YAML file. The Azure Template also can achieve it. You can choose one as you want.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
  • Thanks for your help. But where should I run this YAML file in? Another question is in this YAML file, it seems that it is creating 2 container aci-tutorial-app & aci-tutorial-sidecar? Thank you :) – Evelyn Omo Mar 19 '20 at 04:17
  • @EvelynOmo Do you see the link I provide for you? It shows steps that deploy the YAML file. And yes, it will create two containers in one container group. It's the only way to run multiple containers in the ACI. – Charles Xu Mar 19 '20 at 05:47
  • @EvelynOmo Any more questions? Or what you expect? – Charles Xu Mar 19 '20 at 09:17
  • I am not able to run this yaml file in cli. I faced multiple error occurred: 'BadRequest':'InaccessibleImage. Do I need to run container aci-tutorial-app and aci-tutorial-sidecar in my aci first? – Evelyn Omo Mar 19 '20 at 09:26
  • @EvelynOmo Can you share your YAML file? And how do you set the `imageRegistryCredentials`? – Charles Xu Mar 19 '20 at 09:27
  • Hi Charles, i edited my question with my YAML file. Do let me know if you need more information. Thanks a lot :) – Evelyn Omo Mar 19 '20 at 09:34
  • @EvelynOmo OK, it seems no problem. Can you login through the docker login command with the ACR credential? And what ACR credential do you use? Service principal or the admin? – Charles Xu Mar 19 '20 at 09:37
  • i uses service principal. I think it is working. Thanks a lot for your help. – Evelyn Omo Mar 20 '20 at 01:16
  • @EvelynOmo If it works for you please accept it as the answer. – Charles Xu Mar 20 '20 at 05:58