I have setup a simple flask application in a docker container. My docker file is as follows:

FROM python
ADD . /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 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?


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.