【问题标题】:"http://127.0.0.1:8000/ might be temporarily down" after dockerized badgr-serverdockerized badgr-server 后“http://127.0.0.1:8000/ 可能暂时关闭”
【发布时间】:2019-08-06 10:34:51
【问题描述】:

我正在尝试 dockerize django/python 项目:来自here 的 badgr-server: 我成功地将它部署在没有 docker 的 ubuntu 18.04 上的 localhost 上。 然后我尝试 dockerize,构建进行得很顺利。当我这样做的时候:

docker container run -it -p 8000:8000 badgr python root/badgr/code/manage.py runserver 并且 localhost:8000 上没有任何内容

注意:docker container run -it -p 8000:8000 badgr python ./manage.py 不起作用。

输出:

?: (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.

我在 setting_local.py 中将 ALLOWED_HOSTS 更改为: ALLOWED_HOSTS = ['*'] 谢谢! ** 非常欢迎额外的建议!**

这是 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

【问题讨论】:

  • 不确定你的 docker 容器的 IP 地址是 127.0.0.1(从主机上看),你不应该使用不同的 IP 吗?有关一些可能的提示,请参阅here
  • 谢谢,我用ubuntu 18.04做docker的宿主机。我试图从 docker inspect ``` 获取 IP 地址 ``` 也不工作......

标签: python django dockerfile


【解决方案1】:

docker container run --net=host -it -p 8000:8000 badgrrr python root/badgr/code/manage.py runserver 成功了!

有谁知道为什么它在默认网络上不起作用?

像 dis 一样运行有错吗? 发送。

【讨论】:

  • 你发布了图片吗?
猜你喜欢
  • 2012-08-27
  • 1970-01-01
  • 1970-01-01
  • 2020-12-18
  • 2019-05-22
  • 1970-01-01
  • 2011-09-28
  • 2013-10-10
  • 2018-01-20
相关资源
最近更新 更多