当我运行docker-compose up时,Django开始加载。它经过大约四个步骤。完成系统检查并确定(0个问题)后,它将停止显示当前日期和时间。这就是它挂起的地方。什么也没发生。
C:\Users\********\Desktop\code\hello>docker-compose up
Creating hello_web_1 ... done
Attaching to hello_web_1
web_1 | Watching for file changes with StatReloader
web_1 | Performing system checks...
web_1 | System check identified no issues (0 silenced).
web_1 | August 21, 2019 - 17:33:11
当我执行docker-compose down时,系统退出Gracefully(lol)。然后我运行docker-compose日志,它显示正确的信息:
C:\Users\********\Desktop\code\hello>docker-compose logs
Attaching to hello_web_1
web_1 | Watching for file changes with StatReloader
web_1 | Performing system checks...
web_1 | System check identified no issues (0 silenced).
web_1 | August 21, 2019 - 17:36:44
web_1 | Django version 2.2.3, using settings 'hello_project.settings'
web_1 | Starting development server at http://0.0.0.0:8000/
web_1 | Quit the server with CONTROL-C.
web_1 | Watching for file changes with StatReloader
web_1 | Performing system checks...
web_1 | System check identified no issues (0 silenced).
web_1 | August 21, 2019 - 17:55:22
web_1 | Django version 2.2.3, using settings 'hello_project.settings'
web_1 | Starting development server at http://0.0.0.0:8000/
web_1 | Quit the server with CONTROL-C.
这是我的Dockerfile和docker-compose.yml的样子:
#Dockerfile:
#Pull base image
From python:3.7-slim
#Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
#Set work directory
WORKDIR /code
#Install dependencies
COPY Pipfile Pipfile.lock /code/
RUN pip install pipenv && pipenv install --system
#Copy project
COPY . /code/
#*docker-compose.yml:
web:
build: .
command: python /code/manage.py runserver 0.0.0.0:8000
ports:
- "8000:8000"```