I have a docker image successfully built on my mac. I am running this image by typing docker run -p 8000:8000 . Django server is up and ready to accept requests. but when I request to given URL via postman I am getting an error: socket hangs up. Here is my docker file.
FROM python:3.6-slim-stretch
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY requirements.txt requirements.txt
RUN apt-get -y update
RUN apt-get install -y --fix-missing \
build-essential \
cmake \
gfortran \
git \
wget \
curl \
graphicsmagick \
libgraphicsmagick1-dev \
libatlas-base-dev \
libavcodec-dev \
libavformat-dev \
libgtk2.0-dev \
libjpeg-dev \
liblapack-dev \
libswscale-dev \
pkg-config \
python3-dev \
python3-numpy \
software-properties-common \
zip \
&& apt-get clean && rm -rf /tmp/* /var/tmp/*
RUN cd ~ && \
mkdir -p dlib && \
git clone -b 'v19.9' --single-branch https://github.com/davisking/dlib.git dlib/ && \
cd dlib/ && \
python3 setup.py install --yes USE_AVX_INSTRUCTIONS
RUN pip3 install --default-timeout=100 future
RUN pip3 install -r requirements.txt
COPY . .
CMD python3 manage.py makemigrations face && python3 manage.py migrate && python3 manage.py runserver
The browser also responding by the server didn't send data. Please help me.
Django's runserver
command listens on 127.0.0.1 (the loopback interface) by default, since it's meant for development, not production.
In order for something to be -p
ublishable from a Docker container to the outside world, it needs to listen on 0.0.0.0
, i.e. all interfaces.
Add that to your runserver
invocation...
CMD python3 manage.py migrate && python3 manage.py runserver 0.0.0.0:8000