I have a Docker container running on my Ubuntu Linux 14.04 machine that exposes a port publicly:
docker run --name spacyapi -d -p 127.0.0.1:7091:7091 jgontrum/spacyapi:en
I can connect and execute commands against the server in the container without problem from the local machine. For example:
curl http://localhost:7091/api --header 'content-type: application/json' --data '{"text": "This is a test."}' -X POST
The command executes faithfully. However, if I try the same CURL command from an external machine I get a "connection refused" error:
curl http://192.5.169.50:5000/api --header 'content-type: application/json' --data '{"text": "This is a test."}' -X POST
curl: (7) Failed to connect to 192.5.169.50 port 7091: Connection refused
Where 192.5.169.50 is the IP address of the box running the Docker container.
I don't think I need any iptables rules because I didn't need to set any up for the Node.JS server running on the same box. All the other computers on my local network can access the Node.JS server just fine. But not the Docker container acting as a server.
How can I fix this?