Docker Community Forums

Share and learn in the Docker community.

Can not reach service on host even though port is exposed and mapped

Hi,
So I am trying to dockerize airflow service.
Here’s how my Dockerfile looks

FROM python:3.8.0
# Skipping the steps of creating directory structure and install requirements
COPY airflow.cfg /airflow
EXPOSE 8080

and here’s my docker-compose.yml

version: "3"
services:
    airflow-webserver:
      container_name: airflow-webserver
      build:
        context: .
        dockerfile: Dockerfile
      command: airflow webserver
      ports:
        - 8080:8080
      volumes:
      - .:/project
      environment:
      - AIRFLOW_HOME=/airflow
      - PYTHONPATH=/project

Now when I do $ docker-compose up, I can see that the service is running

airflow-webserver    |   ____________       _____________
airflow-webserver    |  ____    |__( )_________  __/__  /________      __
airflow-webserver    | ____  /| |_  /__  ___/_  /_ __  /_  __ \_ | /| / /
airflow-webserver    | ___  ___ |  / _  /   _  __/ _  / / /_/ /_ |/ |/ /
airflow-webserver    |  _/_/  |_/_/  /_/    /_/    /_/  \____/____/|__/
airflow-webserver    | [2020-04-27 07:39:24,941] {__init__.py:51} INFO - Using executor SequentialExecutor
airflow-webserver    | [2020-04-27 07:39:24,942] {dagbag.py:396} INFO - Filling up the DagBag from /maiden/airflow_dags/
airflow-webserver    | Running the Gunicorn Server with:
airflow-webserver    | Workers: 4 sync
airflow-webserver    | Host: localhost:8080
airflow-webserver    | Timeout: 120
airflow-webserver    | Logfiles: - -
airflow-webserver    | =================================================================            
airflow-webserver    | [2020-04-27 07:39:29 +0000] [11] [INFO] Starting gunicorn 19.10.0
airflow-webserver    | [2020-04-27 07:39:29 +0000] [11] [INFO] Listening at: http://127.0.0.1:8080 (11)
airflow-webserver    | [2020-04-27 07:39:29 +0000] [11] [INFO] Using worker: sync

I can also see that on host, 8080 is being used by docker and service is running on doing $ docker ps

CONTAINER ID        IMAGE                      COMMAND                  CREATED              STATUS              PORTS                    NAMES
567a20295693        maiden_airflow-webserver   "airflow webserver"      About a minute ago   Up About a minute   0.0.0.0:8080->8080/tcp   airflow-webserver

But on my browser, when i go to localhost:8080 or 127.0.0.1:8080 I am unable to get anything.
I even did $ docker inspect 567a20295693 and tried to reach 172.20.0.2:8080 from the IP address mentioned in it, but still could not reach it.
An I doing something wrong?

And if you go to 0.0.0.0:8080 it works?

We just have the same problem. Previously localhost worked and forwarded to our frontend container. Now with the latest update it seems to have been broken.

Apparently just opening Chrome in incognito and localhost starts working…

Hi, No it does not work on 0.0.0.0:8080 either.