Docker-compose in Azure - DNS not working

Viewed 595

I'm trying to deploy a docker-compose file in Azure, my compose file looks like the below.

version: '3'
services:
  db:
    image: mysql:latest
    restart: unless-stopped
    volumes:
      - misp-mysql:/var/lib/mysql
    environment:
      - MYSQL_DATABASE=*****
      - MYSQL_USER=*****
      - MYSQL_PASSWORD=********
      - MYSQL_ROOT_PASSWORD=********
  web:
    image: *****
    restart: unless-stopped
    ports:
      - "80:80"
    volumes:
      - misp-web:/var/www/MISP
    environment:
      - MYSQL_HOST=db
      - MYSQL_DATABASE=****
      - MYSQL_USER=*****
      - MYSQL_PASSWORD=************

When I deploy this to Azure, both containers start and run, as well as a third container 'aci--dns--sidecar', which I assume is for DNS resolution. However, from within the web container, it's impossible to resolve the DB container for me.

Any suggestion?

1 Answers

When you run multiple containers in the Azure Web App, there is only one container you can expose to the outside, and the port only can be one the 80 or 443. And inside the Web App, the containers can communicate with each via the container name and the port that it's exposed. For yours, you can access the DB container with the db:port from the web container, and I recommend you export the port which the DB needs to use first.

Related