Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot access server in docker container

I started a docker image using

docker run --interactive --tty node_web_1

And the running server inside the container successfully prints

Running on http://localhost:8080

in the console. I have exposed port 8080 in the Dockerfile. So in my understanding, when I call http://localhost:8080 in the browser in windows, I should access the server in the container, right? I get no reply though....

How do I go about finding the error? I executed the command

docker-machine ls

as suggested here How to access Docker container's web server from host but apparently I have no docker-machines running? What are those machines? Do I need them? I have only docker for windows installed, no additionall packages or shells.

like image 762
Phil Avatar asked Dec 11 '16 17:12

Phil


People also ask

How do you access a service inside a Docker container?

To access the service from inside the container you need the port that particular host is listening to as no matter where the service is running we need to access it through the host node. If you have a service running on some other port you can access it via 172.17. 42.1:5432.

How do I communicate between Docker container and host?

Here's the gist: For containers to communicate with other, they need to be part of the same “network”. Docker creates a virtual network called bridge by default, and connects your containers to it. In the network, containers are assigned an IP address, which they can use to address each other.

How do I make my Docker container accessible from network?

Public Networking Your Docker container can connect to the outside world, but the outside world cannot connect to the container. To make the ports accessible for external use or with other containers not on the same network, you will have to use the -P (publish all available ports) or -p (publish specific ports) flag.


1 Answers

try to publish your port

docker run -p 8080:8080 -it node_web_1
like image 145
stasovlas Avatar answered Oct 17 '22 20:10

stasovlas