Reputation: 11
Based on image 'python:2.7', I created two containers: container1, container2
Dockerfile for test1:
FROM python:2.7
EXPOSE 6789
CMD ["bash", "-c", "'while true;do sleep 1000;done;'"]
Dockerfile for test2:
FROM python:2.7
EXPOSE 9876
CMD ["bash", "-c", "'while true;do sleep 1000;done;'"]
Then I built two new images with the dockerfiles above, named: test1, test2
Container1:
docker run --name container1 test1
And I also setup a Django server on port 6789 in container1 with:
#In Django workspace
./manage.py runserver 6789
Container2:
docker run --name container2 --link container1:container1 test2
And I also setup a Django server on port 9876 in container2 with:
#In Django workspace
./manage.py runserver 9876
In container2, when I run
curl container1_ip:6789
I got connection refused error.
How can I configure it to make it work?
I also created a container with official nginx image, it has two default ports (80, 443) exposed, and then created another container linked to nginx container, in the container, I did the same thing
curl nginx_ip:80 #successful
and
curl nginx_ip:443 #connection refused
Why this happen? Why 80 works well, and 443 doesn't work?
Upvotes: 0
Views: 451
Reputation: 325
What are you trying to do by "curling" port 6789/9876 of your container ? is there anything (a ftp server or something else?) behind these ports ?
Before trying to reach it from the other container, you should try reaching it from the container itself
In container1 :
curl container1_ip:6789
I think you can access these ports, but there is just nothing listening to them on your container.
EDIT : If you downvote me, please comment explaining why, so i can improve my answers, thanks.
Upvotes: 1
Reputation: 11
The problem is not how to configure docker, it is some config issue about Django. Django is listening localhost:port by default, we should specify a ip address to listen, or with '0.0.0.0' to make it listen all ip address.
Upvotes: 0