Use docker compose in Azure

Viewed 31

I have a pipeline running the following docker-compose-file:

version: '3.4'

services:

  # PostgreSQL Server
  projectservicedb:
    image: postgres:13
    restart: always
    environment:
      - POSTGRES_USER=projectservice
      - POSTGRES_PASSWORD=projectservice
      - POSTGRES_DB=projectservice
    ports:
      - 5432:5432
    volumes: 
      - ./CreateSchema.sql:/docker-entrypoint-initdb.d/CreateSchema.sql    
    hostname: projectservicedb
    
  # projectservice running as WebService
  projectservice:
    image: myregistry.azurecr.io/projectservice
    depends_on:
      - projectservicedb
    ports:
      - 81:80
      - 442:443
    build:
      context: .
      dockerfile: ProjectService/Dockerfile
      
volumes:
  projectservicedb:
    driver: local

So there's a service-image that depends on a db-image. My pipeline has two DockerCompose@0-steps: one for building the images and one for pushing them. Both use the above compose-file.

Now my question: how do I run an instance for that compose-file on Azure? Do I need two seperate container-instances or can I use a single one that contains both the images?

Currently I have an App-Service with a web-hook, so whenever a new image is pushed to my private registry for the projectservice-image, a new instance of the service is created. However for the DB there is no image within my registry, as it's just pulled from official repo. So I don't know how to access the DB from my App-Service.

Another approach is to use an App Service using the Docker-compose (preview)-feature.

However when I use the above docker-compose.yaml-file, I get the following error within the deployment-center:

Exception in multi-container config parsing: YamlException: (Line: 16, Col: 9, Idx: 308) - (Line: 16, Col: 72, Idx: 371): Bind mount must start with ${WEBAPP_STORAGE_HOME}.

1 Answers

If you are referring to App Services (I noticed you also mentioned container instances (ACIs)), then note that docker-compose continues to be in a preview mode and some of it's features are not supported. In particular, the depends_on feature you are using above. The most reliable way is to establish that sequence programmatically.

You can deploy both or multiple images in a single App Service but only one can be exposed to the load balancer and thus to the public internet.

Related