Hi. I’m running my server with Docker python 3.7 image on an EC2 instance using Ubuntu.
I’m running an django application and there is no layers including Nginx or uWSGI.
It works fine for a couple of hours but the problem arises some hours later. Suddenly I can’t access to my django application on a container from the host.
I know the common case of this is like the following.
- not to EXPOSE the PORT to run django app.
- to run the django app on localhost or 127.0.0.1
But I’m not those cases. I wrote EXPOSE 8000
in my Dockerfile
to expose my container port to the host and ran the django app via python manage.py runserver 0:8000
As the inspect of the container(docker inspect {container}
), the IP of the container is 172.17.0.2
and I should be able to access the container via curl http:// 172.17.0.2:8000/
and I can make it.
But as I just said, after some hours I can’t access to the container, http://172.17.0.2:8000
.
(I mean from the host by typing curl http://172.17.0.2:8000
)
I checked lots of things. (Let’s guess the name of my container is myCont
)
docker ps
- myCont
is alive
docker exec -it myCont bash
-> ps -ef | grep python
-> Django process inside myCont is alive.
docker exec -it myCont bash
-> curl http://127.0.0.1:8000
this works well.
-> curl http://172.17.0.2:8000
this also works well! <- I think this is the evidence my Container is working well.
I think it’s not the health problem of the container because I was able to check it out that it works well at least inside the container. So I guess this is an issue with security or something…( I’m not using UFW by the way)