skip to Main Content

I’ve created a small dash app and trying to run on docker container.I get the following message

Dash is running on http://127.0.0.1:8050/

But when I try opening the link it shows trouble connecting to the page.
I tried the solution on Docker image not running on host 8050 but it doesn’t work as well.

My dockerfile:

FROM python:3.9

ADD main.py .

RUN pip install dash

RUN pip install plotly

RUN pip install pandas

RUN pip install flask

EXPOSE 8080/tcp

CMD [ "python3" ,"./main.py" ]

2

Answers


  1. As others said, you need to change the port you’re exposing to 8050

    FROM python:3.9
    
    ADD main.py .
    
    RUN pip install dash
    
    RUN pip install plotly
    
    RUN pip install pandas
    
    RUN pip install flask
    
    EXPOSE 8050
    
    CMD [ "python3" ,"./main.py" ]
    

    to run using docker run

    docker run -p 8050:8050 <image_id>
    

    you should then be able to access it at http://127.0.0.1:8050/

    Login or Signup to reply.
  2. Dockerfile like this

    FROM python:3.9
    
    WORKDIR /code
    COPY main.py /code
    RUN pip install dash plotly pandas flask
    EXPOSE 8050
    CMD python main.py
    

    and build it
    docker build -t YOURAPP:latest .

    and run it
    docker run -p 8050:8050 YOURAPP:latest

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search