Reputation: 691
I have tried specifying -p 23456:23456 and -P, and I'm using my application for robotics where it establishes a two-way communication over that port. From the container to the Vehicle Driver Computer, it sends messages that reach it because it "comes online". However, it fails quickly after and I believe it's because it can't send messages over that port into the docker container and it times out.
I've seen this post about why you can't ping a container from a computer on a local network, but what can I do to workaround this? I need a computer on a local network to communicate with a docker container.
Thanks for any help.
Upvotes: 1
Views: 1478
Reputation: 4542
your container send message to the vehicle driver directly, but your vehicle driver should send its message to the machine where the docker is located on the port 23456 in your case (it is docker that listen on that port and forward it to the right container)
example: docker run --name container-name -p 80:8080 container-image
to reach it you should ping dockerhost:80 and that would forward the ping on the container port 8080 from https://docs.docker.com/engine/userguide/networking/default_network/binding/
By default Docker containers can make connections to the outside world, but the outside world cannot connect to containers. Each outgoing connection will appear to originate from one of the host machine’s own IP addresses thanks to an iptables masquerading rule on the host machine that the Docker server creates when it starts
Upvotes: 2