Reputation: 579
I am trying to connect a script on a Docker host to a script on a Docker container.
The scripts are using Python's remote queue manager, and they work perfectly outside of Docker, so I'm quite sure the issue is with my Docker configuration or my understanding of Docker port forwarding.
The script on the container binds correctly to (localhost,5800), and I verified the script does not crash.
I've tried getting the script to connect to the IP address of the container on port 5800, and that doesn't work (Connection refused). I've also tried using the -p flag and forwarding 5800 to a random port, then connecting to (localhost,randomport) from the Docker host and that doesn't work either (Connection refused).
Again, the script is definitely running, since the issue occurs even when I get a shell on the container and manually launch the script, ensuring it successfully launches the server and does not shut it down.
To me this seems like the exact same problem as running a webserver within a Docker container. Why is this not working? The scripts work outside of Docker just fine.
https://github.com/hashme/thistle/tree/flask_thistle
(see room.py for container script and app.py for host script; I'm not running the scripts exactly but hacking away in a REPL, so I've adjusted many parameters without success)
To replicate the problem, first run ./container.sh, then (in a REPL) import app and create a MessagePasser with some IP address and port number. Running the app.py script does nothing.
Upvotes: 0
Views: 686
Reputation: 146164
The script on the container binds correctly to (localhost,5800)
You need to make sure that within the container the script binds to the "0.0.0.0" (all interfaces) address, not localhost (loopback). Otherwise it won't be able to accept any external connections.
Upvotes: 1