<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>

CC BY-SA 4.0
2019-08-03T10:49:35.963Z
2019-08-03T10:49:35.963Z
user2683038
<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>

<docker>
Not possible to ping or reach a container under its local IP
user2683038
# 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  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."


---

