使用Dockerfile构建一个django项目

公司使用docker流程(以图书管理系统为例)

第一步:有一个项目,pycharm开发着,开发完后


第二步:在项目路径下新建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端口就能看到项目了

10.0.0.100:8080

第八步:开发人员继续提交代码


第九步:运维人员pull代码,重启容器,用户就可以看到最新的了

posted @ 2024-03-14 21:33  wellplayed  阅读(48)  评论(0编辑  收藏  举报