0

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>

  • Run server on Linux machine (just using nodejs without a container)
  • On Mac (client) computer run curl <name of linux computer>.local:3000
  • Works as expected

Testing connection to server on localhost while running inside of a Docker container

  • Run server on Linux machine inside of a container using the command docker run -p 127.0.0.1:3000:3000 <name of image>
  • On Linux machine run curl localhost:3000
  • Works as expected

Testing connection to separate computer while running server in Docker container

  • Run server on Linux machine inside of a container using the command docker run -p 127.0.0.1:3000:3000 <name of image>
  • On mac machine run curl <name of linux computer>.local:3000
  • No response from server

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.