0

Say on the host machine I have a server running on localhost:4000. How do I connect to that server from inside a Docker container?

This is a security risk in some cases, but in my case, this is running on my personal machine, so I can give the container all the privileges it needs to talk with the host machine.

For example in the Docker container, if I run:

RUN nc localhost 4000 | xargs echo

I don't think that's going to to be able to connect to the server running on the host, unless I take some extra steps.

  • I guess you will have to map the the port to the host: `docker run -d -p 4000:4000 --name example example` – Cyclonecode May 14 '18 at 07:38
  • I think this link might be useful: https://stackoverflow.com/questions/17770902/forward-host-port-to-docker-container – Cyclonecode May 14 '18 at 07:43

0 Answers0