title: Is it possible to send HTTP requests from inside a running Docker container
body: <p>I have a basic distributed system that calculates the average cyclomatic complexity across all commits of a Github repo. It consists of a Master node running on Flask that gives SHA ID's to a set of Worker nodes when they send a GET request to the Master.</p>
  
  <p>I was trying to get some practice with Docker, and wanted to put my Worker code in a Docker container, then put that container on a set of remote machines and have the Master run on my local machine. I wanted the Workers and Master to be able to communicate with one another. </p>
  
  <p>I'm not clear on how to go about doing this. I have tried telling the Worker nodes to send their requests to my local machines public IP and the port that the Flask server is running on (5000). I have mapped the port 5000 of the remote machine to port 5000 of the Docker container. That is about the extent of my knowledge here. I'll attach some relevant code snippets below, without copy pasting the entire program.</p>
  
  <p>Master setup:</p>
  
  <pre><code>if __name__ == '__main__':
      get_commits()
      TOTAL_COMMITS = len(JOB_QUEUE)
      app.run(host='0.0.0.0', port=5000, debug=False)
      print('\n-----Shutting Down Server-----')
      calc_avg_cc()
  </code></pre>
  
  <p>Worker URLS:</p>
  
  <pre><code>master_url = 'http://&lt;my public ip&gt;:5000/'
  node_setup_url = 'http://&lt;my public ip&gt;:5000/init'
  </code></pre>
  
  <p>-------------------------------------Edit---------------------------------</p>
  
  <p>As @odk and @jonasheinisch suggested, it was in fact a network error. I was deploying my docker container on a remote machine that was on my university network. I spun up two AWS instances, one for Master and one for Worker's and hey presto it worked.</p>
  
  <p>I've updated the setup now, and will provide a bit more context as requested. One thing that I am still unsure of is exactly how my requests from my Worker are making it to my Master. I have mapped port 80 on the host to port 80 on the Docker container, as shown in my Dockerfile below. I chose port 80 as a bit of a guess, because I know that it is associated with HTTP traffic.</p>
  
  <p>Dockerfile:</p>
  
  <pre><code># Use an official Python runtime as a parent image
  FROM python:3.5-slim
  
  # Set the working directory to /worker
  WORKDIR /worker
  
  # Copy the current directory contents into the container at /app
  ADD worker.py requirements.txt github-token ./
  
  # Install any needed packages specified in requirements.txt
  RUN pip install -r requirements.txt
  
  # Make port 80 available to the world outside this container
  EXPOSE 80
  
  # Run app.py when the container launches
  CMD ["python", "worker.py"]
  </code></pre>
  
  <p>New Worker setup:</p>
  
  <pre><code>master_url = 'http://&lt;public IP of my AWS Master Instance&gt;:5000/'
  node_setup_url = 'http://&lt;public IP of my AWS Master Instance&gt;:5000/init'
  </code></pre>
  
  <p>Master is still listening on all interfaces on port 5000. How exactly do my requests (sent from the Python request library) make it outside the Docker container to the Internet?</p>