使用Dockerfile构建django项目

使用Dockerfile构建django项目

第一步,新项目在pycharm开发完

image

第二步,在项目路径下新建Dockerfile写入

FROM python:3.9
MAINTAINER zeng
WORKDIR /soft
COPY ./requirements.txt /soft/requirements.txt
RUN pip install -r requirements.txt -i https://pypi.doubanio.com/simple
CMD ["python","manage.py","runserver","0.0.0.0:8080"]

第三步:把代码提交到git

第四步:运维人员在服务器的项目路径把代码拉下来

git clone https://gitee.com/liuqingzheng/books.git

第五步:构建镜像

docker build -t='django_books' .

第六步:运行容器

docker run -id --name=books -v /root/books:/soft -p 8080:8080 django_books:latest

访问宿主机的8080端口就能看到项目了

服务器IP:8080
posted @ 2024-06-26 16:43  逸仔学Linux  阅读(77)  评论(0)    收藏  举报