Django app expose port help

Hi guys

I’m struggling to access a django app on the host browser(i.e chrome, mozilla). I’m new to docker so I don’t know what if I’m confusing stuff.
My app is running in docker container and I can to a curl on ip address and port and I will get the desired page.
Once django is up and running on port 8000 I attempted to use several options expose django port to the host:

  1. docker run -d -p 80:8000 image
  2. docker expose…

This does not work I can see that a new container is created after this but it’s immediately shutdown. Does docker run/expose work only if I use Dockerfile or docker-compose.yml?.

I also attempted to use iptables on the container but I get the following error if I try to add rules:

iptables v1.4.21: can’t initialize iptables table `filter’: Permission denied (y
ou must be root)
Perhaps iptables or your kernel needs to be upgraded.

I’m looking to the easiest option. I would not necessarily want to create a Dockerfile where I should specify the exposed port.

maybe the issue is related to your docker installation.
Cause the command you run should work and should expose the port.
To check if it is an issue with your installation, you could try to execute your command within http://play-with-docker.com

Are you certain that port 80 isn’t already in use on your machine by another app? If it is, an error will be thrown and visible in the logs. Change your command to
docker run -d -p 80:8000 --name CONTAINER_NAME image

Then access logs using:
docker logs CONTAINER_NAME

hi

Thanks for the update. Is not working as after I start the container it immediately shuts down. If I run docker ps it will not show that container. Obviously docker logs container_name doesn’t show anything. As far as I can see docker is only supported on windows 10. I’m using windows 7 and to run docker I used kitematic. Also it seems there where a couple of thread on docker forum explaining why docker can’t expose container port to the host due to Windows networking stack. I don’t know if that should work atm on my Windows 7 with kitematic.