Django Docker app container don't open on browser after run

Viewed 885

I dockerize my django app, this is my Dockerfile:

FROM python:3.6-alpine
EXPOSE 8000
RUN apk add --no-cache make linux-headers libffi-dev jpeg-dev zlib-dev
RUN apk update && apk add postgresql-dev gcc python3-dev musl-dev
RUN mkdir /Code
WORKDIR /Code
COPY ./requirements.txt .

RUN pip install --upgrade pip
RUN pip install -r requirements.txt
ENV PYTHONUNBUFFERED 1

COPY . /Code/

ENTRYPOINT python /Code/core/manage.py runserver 0.0.0.0:8000

well, i build my image and I run it:

docker run -p 8000:8000 --link postgres:postgres cath11/test_app

all seems to be done:

enter image description here

but when I open my browser on http://0.0.0.0:8000/ or http://127.0.0.1:8000/ my app does not open

enter image description here

Why my django app seems running on my container, I expose port but I cannot see it in my hosted browser?

So many thanks in advance

1 Answers

Use docker-machine ip default to check for the IP, and use it instead of localhost. Technically, the django app is served inside the container, not your local host.

So in your case, you should try http://<ip from the command>:8000/

Related