Answers: <p>I think I found the answer here: <a href="https://docs.docker.com/docker-for-mac/networking/#known-limitations-use-cases-and-workarounds" rel="nofollow noreferrer">https://docs.docker.com/docker-for-mac/networking/#known-limitations-use-cases-and-workarounds</a>. It's not working under OS X: "Docker Desktop for Mac can’t route traffic to containers."</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-08-03T10:49:35.963Z
Answers: 2019-08-03T10:49:35.963Z
Answers: user2683038
Body: <p>I have setup a simple flask application in a docker container. My docker file is as follows:</p>
  
  <pre><code>FROM python
  ADD . /app
  WORKDIR /app
  RUN pip install -r requirements.txt
  CMD ["python", "myFlask.py"]
  </code></pre>
  
  <p>I start the container using </p>
  
  <pre><code>docker run -d myContainer
  </code></pre>
  
  <p>I retrieve the internal IP address by</p>
  
  <pre><code>docker exec -ti &lt;containerID&gt; cat /etc/hosts
  </code></pre>
  
  <p>and it's 172.17.0.2. When I try to ping this address or try to access the REST API using curl I cannot reach it. When I use port forwarding using <code>-p 5000:5000</code> as part of the run command I can reach the REST API under localhost:5000. I am working under OS X.</p>
  
  <p>Why can't I reach the container under its local IP?</p>
  
Tags: <docker>
Title: Not possible to ping or reach a container under its local IP
UserDisplayName: user2683038
ThreadText: # Not possible to ping or reach a container under its local IP
  
  (Asked by: username_0 on 2019-08-03)
  
  I have setup a simple flask application in a docker container. My docker file is as follows:
  
  ```
  FROM python
  ADD . /app
  WORKDIR /app
  RUN pip install -r requirements.txt
  CMD ["python", "myFlask.py"]
  
  ```
  
  I start the container using
  
  ```
  docker run -d myContainer
  
  ```
  
  I retrieve the internal IP address by
  
  ```
  docker exec -ti <containerID> cat /etc/hosts
  
  ```
  
  and it's 172.17.0.2. When I try to ping this address or try to access the REST API using curl I cannot reach it. When I use port forwarding using `-p 5000:5000` as part of the run command I can reach the REST API under localhost:5000. I am working under OS X.
  
  Why can't I reach the container under its local IP?
  
  **Tags:** docker
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2019-08-03. Score: 0 | Accepted answer
  
  I think I found the answer here: <https://docs.docker.com/docker-for-mac/networking/#known-limitations-use-cases-and-workarounds>. It's not working under OS X: "Docker Desktop for Mac can’t route traffic to containers."
  
  
  ---
  
  