Receiving http response inside a Docker container

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?

  • How to get two Docker containers talking to each other?
  • How to test dockerignore file?
  • Docker on CentOS with bridge to LAN network
  • Running multiple docker containers in same host
  • 'No space left on device' after I changed Docker's storage base directory with DOCKER_OPTIONS
  • Securing docker containers
  • docker cp to container: file name too long
  • How can I set parameters from docker command line to configure spring boot application?
  • Docker volumes are partitions or subdirectories?
  • Connect to Docker API from Windows to external server
  • How to copy and rename a Docker container?
  • Docker newbie setup troubles
  • One Solution collect form web for “Receiving http response inside a Docker container”

    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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.