0

I'm trying to dockerize django/python project : badgr-server from here: I succeed to deployed it on localhost on ubuntu 18.04 without docker. then I tried to dockerize, the build went well. when I did :

docker container run -it -p 8000:8000 badgr python root/badgr/code/manage.py runserver and there is nothing on localhost:8000

note: docker container run -it -p 8000:8000 badgr python ./manage.py won't work.

output:

?: (rest_framework.W001) You have specified a default PAGE_SIZE pagination rest_framework setting,without specifying also a DEFAULT_PAGINATION_CLASS.
   HINT: The default for DEFAULT_PAGINATION_CLASS is None. In previous versions this was PageNumberPagination. If you wish to define PAGE_SIZE globally whilst defining pagination_class on a per-view basis you may silence this check.

System check identified 1 issue (0 silenced).
August 06, 2019 - 10:01:22
Django version 1.11.21, using settings 'mainsite.settings_local'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

I changed in setting_local.py the ALLOWED_HOSTS to : ALLOWED_HOSTS = ['*'] Thanks! ** extra advises are more than welcome!**

this is the Dockerfile :

FROM ubuntu:18.04

# Preparation
RUN apt-get update

# Install server dependencies
RUN apt-get install -y curl git git-core python-virtualenv gcc python-pip python-dev libjpeg-turbo8 libjpeg-turbo8-dev zlib1g-dev libldap2-dev libsasl2-dev swig libxslt-dev automake autoconf libtool libffi-dev libcairo2-dev libssl-dev
RUN pip install virtualenv --upgrade 
#RUN apt install libjpeg8-dev zlib1g-dev -y libcairo2
RUN pip install pillow

# Install database

 Run apt-get install -y libmariadbclient-dev zlib1g-dev  libssl-dev 

# Install main dependencies
Run apt-get install -y libffi-dev libxslt-dev libsasl2-dev libldap2-dev
Run apt-get install -y libmariadbclient-dev zlib1g-dev python-dev libssl-dev python-virtualenv

# Install other useful tools
RUN apt-get install -y git vim sudo curl unzip
RUN apt-get install -y sqlite3




# Cleaning
RUN apt-get clean
RUN apt-get purge

# ADD settings.py /root/settings.py
ADD settings_local.py /root/settings_local.py

# Install the backend
RUN mkdir ~/badgr \
  && cd ~/badgr \
  && git clone https://github.com/concentricsky/badgr-server.git code \
  && cd code \
  && pip install -r requirements.txt \
  && cp /root/settings_local.py apps/mainsite/ \
  && ./manage.py migrate \
  && ./manage.py dist 


EXPOSE 8000
  • Not sure the IP address of your docker container is 127.0.0.1 (as seen from the host machine), shouldn't you use a different IP? See [here](https://stackoverflow.com/questions/27191815/how-to-access-docker-containers-web-server-from-host) for some possible hints. – dirkgroten Aug 06 '19 at 10:49
  • Thank you, I'm using ubuntu 18.04 for the host machine of the docker. I tried to get the Ip address ``` from docker inspect ``` not working either... – Daniel Ben Zaken Aug 06 '19 at 12:06

1 Answers1

0

docker container run --net=host -it -p 8000:8000 badgrrr python root/badgr/code/manage.py runserver and it's worked!

Do anyone know why it's doesn't work on the default network?

does it's wrong to run it like dis? Tx.