I am running a process, process A, inside a Docker container that sends an HTTP reqeust to a process, process B, running natively on the host. Process B receives the request and after processing sends a response which process A does not receive. I believe this could be because I am not exposing the port on which the reply is sent. My understanding is that, this source port is randomly chosen and I am not sure how I can expose this port. Is there a way to overcome this issue?
Asked
Active
Viewed 1,991 times
2
-
This is not because of having or not having a port exposed. There may be multiple issues. For start try if you can ping any public IP from a container and share your docker run command. This will help troubleshoot. Also I expect that if you send HTTP request to process A from outside docker it works properly... – mike Nov 16 '15 at 09:27
1 Answers
0
My understanding is that, this source port is randomly chosen and I am not sure how I can expose this port
It is only if your container runs with the -P
option.
If you run with -p hostp_port:container_port
option (with container_port being a port EXPOSE
'd in the Dockerfile
of the image from which the container is running), that will work.

VonC
- 1,262,500
- 529
- 4,410
- 5,250
-
I am not talking about Docker mapping a static internal port to a non-conflicting host port. I am talking about HTTP request opening a source port for communication to an HTTP server (One reference for this I can find is : http://stackoverflow.com/questions/2957757/how-can-an-application-use-port-80-http-without-conflicting-with-browsers) – Phelodas Nov 16 '15 at 05:48
-
@Phelodas so that depends on the exact nature of the service opening that port then. I wouldn't know anything about it. – VonC Nov 16 '15 at 05:49