简体   繁体   中英

How to access a remote django app that's running on docker

I'm currently trying to run a django website through a docker container on an AWS server using Tutum. I've looked at countless ways to access it through my web browser to no avail. I got my public IP like so-

curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

and set the server to run on port 8000 by using a few methods.

python manage.py runserver 0.0.0.0:8000
python manage.py runserver 0:8000

and

./manage.py runserver 0.0.0.0:8000
./manage.py runserver 0:8000

Then, when I try to access the webpage through the external IP and port, I get the webpage not available page. What am I doing wrong? It's just a development server, but there's no reason that I know of that will allow it to be hacked.

Thanks for the help!

In Tutum you check the box corresponding to the container that you want to publish to the web. After that, click edit (unless you are currently creating the container). In that page you will see a box that you need to click on to define a port that will be published to the web. After you click that box you will be able to add a port by clicking "add port". In my case, I added port 80 and clicked the box that says published. It will auto-assign dynamic, but I clicked on dynamic and changed it to 8000. If you already created the container and are editing it, you will need to redeploy the container. If not, then don't worry about redeploying.

Check what your public IP address is by using the following command (you may need to apt-get install curl.

curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

After that, go into your django project folder and type the command

sudo python manage.py runserver 0.0.0.0:80

After doing that, go to your browser and type the public ip with the port 8000 like so-

http://your.public.ip.address:8000

That should take you to your published and running Django web application.

Problem solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM