Docker app not reachable after port-change

139 Views Asked by At

Can you help me figure out why my instance of Adguard Home is working during initial set-up through port 3000, but after completing the set-up I can not access port 80 (and neither can the Azure Web App HTTP health probe)?

Some context: I want to get hands-on experience with Azure in preparation of the AZ-104 exam. Of course, I'm also learning from Microsoft learn as well as those websites that prepare you for the actual questions on the exam.

But I need some practical experience to be able to place the theory, and I like learning by doing. I do have many years of hobby experience with hosting web/mail/dns/proxy/game/smarthome/etc servers, but Azure and Docker are entirely new to me (apart from having a couple Azure foundational certificates). My approach is to install Adguard Home in as much different ways as possible on Azure, to at least touch those aspects of Azure. I've already done this successfully for Windows & Linux VMs, through Azure Container Services and then both using the interface as well as SSH / CLI. However with Azure Web Apps I am stuck.

I was able to successful pull the image from Docker hub. And with some 2 hours of fiddling I figured out how to assign / open ports, start the web server which serves the installation page through port 3000 and how to mount volumes so that the installation is actually persistent between cycles/restarts.

After completing the installation, Adguard Home will switch the port where it serves the webUI to port 80 from port 3000. My thought I that I need to adjust WEBSITES_PORT, EXPOSE and PORT from 3000 to 80. However, even though I know the app is broadcasting on port 80, the probe doesn't detect it and neither can I reach the post-install web UI. Does anyone have an idea what the issue could be? By the way, in the logs (accessed through downloading logs.zip on the Advanced Tools page) Adguard doesn't throw any error. It even throws an info message indicating the webui should be available on 127.0.0.1:80 (and the DNS server on 127.0.0.53).

Could this be because Adguard Home is broadcasting on 127.0.0.1:80 instead of 0.0.0.0:80?

TL;DR App is working correctly and reachable immediately after installation. After configuration the webUI port changes from 3000 to 80, and now the app is not reachable anymore.

Thanks!

1

There are 1 best solutions below

0
Suresh Chikkam On

I have set up an Express.js application along with AdGuard Home in a Docker container, you can use Docker Compose to manage both services. Create a docker compose file and configure the ports as below.

docker-compose.yml:

version: '3'

services:
  express-app:
    image: node:14
    working_dir: /usr/src/app
    volumes:
      - ./express-app:/usr/src/app
    ports:
      - "3000:3000"
    command: ["npm", "start"]

  adguard:
    image: adguard/adguardhome
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "80:80"
    volumes:
      - ./adguard-data:/opt/adguardhome/work
    command: ["./AdGuardHome", "-c", "/opt/adguardhome/AdGuardHome.yaml"]

enter image description here

In the Azure portal, navigate to your Web App, go to "Configuration," and check that WEBSITES_PORT is set to 80 ,even if it is a default port also.

Dockerfile:

# Use the official AdGuard Home image
FROM adguard/adguardhome

# Expose necessary ports
EXPOSE 53/tcp 53/udp 80/tcp

# Set AdGuard Home configuration to bind to all available interfaces
RUN sed -i 's/bind_host: 127.0.0.1/bind_host: 0.0.0.0/' /opt/adguardhome/AdGuardHome.yaml

# Command to run AdGuard Home
CMD ["./AdGuardHome", "-c", "/opt/adguardhome/AdGuardHome.yaml"]
  • Below RUN command uses sed to modify the AdGuard Home configuration file (AdGuardHome.yaml) and change the bind_host from 127.0.0.1 to 0.0.0.0. This modification allows AdGuard Home to listen on all available network interfaces.
    • docker run -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -v /path/to/config:/opt/adguardhome/work --name adguard-home -d my-adguard-home:latest

Docker status:

enter image description here

Result:

enter image description here