使用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 @   逸仔学Linux  阅读(55)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示