简体   繁体   中英

Docker-compose in Azure - DNS not working

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM