I'm trying to connect to a docker container's locally hosted address. I'm using Django to serve a website within the container, and I want to connect to it on my local machine.
How can I access this site from my local machine?
I've tried to inspect the container and found that the local IP address is 172.28.0.4
. Even after specifying the correct port on my browser, it still won't connect.
The port 8000 is exposed in the container already, and added to the list of ports in the compose file.
What can I do to fix this issue?
CodePudding user response:
If you can connect to the docker instance through ssh, try:
ssh [email protected] -L 8000:172.28.0.4:8000
Then navigate to your project and do py manage.py runserver 0.0.0.0:8000
Then on your local machine go to your browser and you should be able to access your app @ http://127.0.0.1:8000