Can't access to public IP of django docker container

Viewed 29

I can access the container with these curl commands:

curl http://localhost:8000/api/health/
curl http://127.0.0.1:8000/api/health/

But I can't access it with public IP address:

curl http://xx.xxx.xxx.xxx:8000/api/health/
curl: (7) Failed to connect to xx.xx.xxx.xxx port 8000 after 0 ms: Connection refused

I used this command to run the container:

docker container run -d --network=host -p 8000:8000 my-central-api

Dockerfile has this line:

CMD [ "python3", "manage.py", "runserver", "0.0.0.0:8000"]

I am running this container on an EC2 instance. I set up the security group and NACL. So I think it is related to docker configuration.

Why I can't access to port 8000 with public IP?

0 Answers
Related