Deploying via Docker Compose to Azure App Service with multiple containers from different sources

Ross Vernal 1 Reputation point
2020-12-04T15:17:06.213+00:00

I have a docker-compose.yml file which is created from a build step in Azure Devops. The build step works well and I can see how the docker-compose.yml file is produced. That makes sense to me.

However, it is looking for a normal docker image to run one of the services and the other service is one I've created and am hosting in my Azure Container Registry.

The docker compose file looks like this:

networks:
  my-network:
    external: true
    name: my-network
services:
  clamav:
    image: mkodockx/docker-clamav@sha256:b90929eebf08b6c3c0e2104f3f6d558549612611f0be82c2c9b107f01c62a759
    networks:
      my-network: {}
    ports:
    - published: 3310
      target: 3310
  super-duper-service:
    build:
      context: .
      dockerfile:  super-duper-service/Dockerfile
    image: xxxxxx.azurecr.io/superduperservice@sha256:ec3dd010ea02025c23b336dc7abeee17725a3b219e303d73768c2145de710432
    networks:
      my-network: {}
    ports:
    - published: 80
      target: 80
    - published: 443
      target: 443
version: '3.4'

When I put this into an Azure App Service using the Docker Compose tab, I have to select an image tab - either Azure Container Registry or Docker Hub - I'm guessing the former because I am connected to that.

When I start the service, my logs say:

2020-12-04T14:11:38.175Z ERROR - Start multi-container app failed
2020-12-04T14:23:28.531Z INFO  - Starting multi-container app..
2020-12-04T14:23:28.531Z ERROR - Exception in multi-container config parsing: Exception: System.NullReferenceException, Msg: Object reference not set to an instance of an object.
2020-12-04T14:23:28.532Z ERROR - Start multi-container app failed
2020-12-04T14:23:28.534Z INFO  - Stopping site ingeniuus-antivirus because it failed during startup.

It's not very helpful, and I don't think there's anything wrong with that docker-compose.yml file.

If I try to deploy ONLY the service from the Azure Container registry, it deploys, but doesn't deploy the other service.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,959 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Ryan Hill 26,146 Reputation points Microsoft Employee
    2020-12-07T16:42:04.417+00:00

    Hi @Ross Vernal ,

    The exception I believe is caused by how you configured your ports. I encountered the same error when using ports: the way you did. After I changed it to:

    ...  
        ports:   
          - "6376:6379"  
    ...  
        ports:   
          - "80:80"  
          - "443:443"  
    

    the docker-compose ran successfully and started the site. I used this Dockercompose from https://learn.microsoft.com/en-us/azure/container-instances/tutorial-docker-compose. I think the following docker compose should work for you. I omitted my-network because I didn't see the use for it here.

     services:  
       clamav:  
         image: mkodockx/docker-clamav  
         ports:  
         - "3310:3310"  
       super-duper-service:  
         build:  
           context: .  
           dockerfile:  super-duper-service/Dockerfile  
         image: xxxxxx.azurecr.io/superduperservice  
         ports:  
         - "80:80"  
         - "443:443"  
      
     version: '3.4'  
    

    Regards,
    Ryan

    3 people found this answer helpful.

  2. Ross Vernal 1 Reputation point
    2020-12-07T10:42:26.503+00:00

    Turns out Azure App Service doesn't really support anything useful with regard to docker-compose:

    https://learn.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux#docker-compose-options

    I'd advise using Azure Container Instances, that seems to handle things a bit better.

    0 comments No comments