Reputation: 197
I'm not sure if this is a networking issue, or a Docker issue, but I'm having a difficult time getting a response from a server on a separate machine in my LAN that is running a nodejs server on port 3000 in a Docker container. I'm using a Mac computer as a client, and a Linux computer as a server. These are the steps I've taken :
Testing connection to separate computer on LAN using <name of computer>.local:<port>
curl <name of linux computer>.local:3000
Testing connection to server on localhost while running inside of a Docker container
docker run -p 127.0.0.1:3000:3000 <name of image>
curl localhost:3000
Testing connection to separate computer while running server in Docker container
docker run -p 127.0.0.1:3000:3000 <name of image>
curl <name of linux computer>.local:3000
Upvotes: 0
Views: 1820
Reputation: 74851
The container will not be accessable external to the Linux host when listening on 127.0.0.1
/localhost
.
To bind to all available interfaces use:
docker run -p 3000:3000 <image>
Or specify the address of a publicly available interface from ip address show
docker run -p <public_ip>:3000:3000 <image>
Upvotes: 1