Dockerfile
# 设置基础镜像
FROM python:3.7
# 设置环境变量
ENV PYTHONUNBUFFERED=1
ENV PATH /usr/local/bin: $PATH
# 设置工作目录
WORKDIR /home/lab
# 复制项目文件到容器中
COPY . /home/lab/
#COPY requirements.txt /home/lab
# 安装依赖包(先更新pip,换源,再安装包)
RUN pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple
# 映射端口
EXPOSE 8000
# 运行Django项目
# CMD python manage.py runserver 0.0.0.0:8888
docker-compose.yaml
version: "3"
services:
app:
build: .
ports:
- "9002:8000"
volumes:
- .:/home/lab
command: python manage.py runserver 0.0.0.0:8000
redis:
image: redis
ports:
- "9003:6379"