How to push muliple images to azure registry

I have a multiple container app that I want to deploy on azure, to create the images I'm using a docker compose file similar to this one:

version: '3.3'

services:

  app1:
    image: app1
    container_name: "app1"
    ports:
      - "5000:5000"
    restart: always
    build:
      context: ./app1
      dockerfile: Dockerfile

  app2:
    image: app2
    container_name: "app2"
    ports:
      - "5000:5000"
    restart: always
    build:
      context: ./app2
      dockerfile: Dockerfile

Which helps me to automate the process, the issue is than every other step after this requires to use comands for each images indivdualy, in the pipeline I have this steps are:

1) Tag the image:

sudo docker tag app1 services.azurecr.io/samples/app1

2) Push the image to the azure registry:

sudo docker push services.azurecr.io/samples/app1

3) Deploy the container:

az container create \
    --name XXX
    --ports  5000 5100 \
    --memory 3 \
    --cpu 1 \
    --azure-file-volume-share-name legaldocuments \
    --azure-file-volume-mount-path /app/data \
    ...
    ...
    ...

Is there a way to include this in a single file for several containers? at least the part of tag and push the image.

Upvotes: 0

Views: 1625

Answers (2)

4c74356b41
4c74356b41

Reputation: 72211

you can use the docker tasks to achieve that (kinda), same is possible in the gui

- task: Docker@2
  displayName: Push image
  inputs:
    containerRegistry: |
      $(dockerHub)
    repository: $(imageName)
    command: push
    tags: |
      test1
      test2
      etc

I dont think the equivalent works for building, so you'd have to have either a script with loop or multiple build steps to build

Upvotes: 1

Sajeetharan
Sajeetharan

Reputation: 222700

To Push Multiple images to Azure Container Registry, they need to be tagged with the loginServer name of the Registry.

Follow the steps

Step 1 : You need to attach a tag to those images,

docker tag azurecontainerservicepoc acrarampoc/azurecontainerservicepoc:dev

Step 2: Push Docker Images to Azure Container Registry

docker push your_acr_name.azurecr.io/elasticsearch:6.2.4

Then inorder to push multiple images, you can try something with Bash script as,

In your case, it would be :

docker push --all-tags   your_acr_name.azurecr.io 

Upvotes: 1

Related Questions