【发布时间】:2021-08-10 22:14:31
【问题描述】:
我在为我的 django 应用程序创建 docker 容器时遇到了一些问题。
我有我的 Dockerfile
FROM python:3.8.6
ENV PYTHONUNBUFFERED 1
USER root
RUN apt-get -y update && \
apt -y install python3-pip && \
pip3 install setuptools gitpython && \
pip install django && \
pip install stripe && \
pip install django-extensions
RUN git clone https://github.com/***/***
WORKDIR /tfg/MiTfg
EXPOSE 8000/tcp
CMD python3 manage.py makemigrations
CMD python3 manage.py migrate
CMD python3 manage.py runserver localhost:8000
完美运行,现在我运行
docker run --network host -p 8000:8000 1fbe
输出打印:
WARNING: Published ports are discarded when using host network mode
System check identified some issues:
WARNINGS:
Tienda.Categoria: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TiendaConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
Tienda.Cliente: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TiendaConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
Tienda.CodigoDescuento: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TiendaConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
Tienda.ContadorSesiones: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TiendaConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
Tienda.Pedido: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TiendaConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
Tienda.Producto: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TiendaConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
Tienda.Productor: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the TiendaConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
System check identified 7 issues (0 silenced).
我认为问题出在连接上,因为如果我在浏览器 localhost:8000 中运行,它会说没有服务器在该目录中运行...所以可能是 docker 和主机之间的网络有问题...? ?
当 django 应用程序在没有 docker 的情况下在本地下载时,我可以完美运行它,因此该应用程序可以工作但不能在容器中...
请帮帮我!!!
谢谢你
【问题讨论】:
标签: python django docker networking docker-networking