'Docker image not running on host 8050

I am trying to teach myself how to deploy a dash application on AWS.

I have created a folder 'DashboardImage' on my mac that contains a Dockerfile, README.md, requirements.txt and an app folder that contains my python dash app 'dashboard.py'.

My Dockerfile looks like this:

enter image description here

I go into the DashboardImage folder and run

docker built -t conjoint_dashboard .

It built successfully and if I run docker images I can see the details of the image.

When I try

docker run conjoint_dashboard

The terminal tells me Dash is running on http://0.0.0.0:8050/ but it is not connecting.

I can't understand why.



Solution 1:[1]

Update it according to your port, e.g. if your application exposes port 8050 then:

docker run -p 8050:8050 conjoint_dashboard where -p = publish first one is the HOST port, and the second is the CONTAINER port.

Also you can update your dockerfile:


FROM: continuumio/minicoda3
...

EXPOSE 8050/tcp

...

The EXPOSE instruction doesn't actually publish the port. It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published.

To actually publish the port when running the container, use the -p flag on docker run to publish and map one or more ports, or the -P flag to publish all exposed ports and map them to high-order ports.

By default, EXPOSE assumes TCP. You can also specify UDP:

Solution 2:[2]

You need to expose the port, see: https://docs.docker.com/engine/reference/commandline/run/#publish-or-expose-port--p---expose

$ docker run -p 127.0.0.1:80:8080/tcp ubuntu bash
This binds port 8080 of the container to TCP port 80 on 127.0.0.1 of the host machine. You can also specify udp and sctp ports. The Docker User Guide explains in detail how to manipulate ports in Docker.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 OneCricketeer
Solution 2 Tin Nguyen