dockerfile是用来构建镜像来用的 pip.conf是配置下载源 requirements.txt是当前所需要的环境 manage.py是启动项目的脚本
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple/ [install] trusted-host= pypi.tuna.tsinghua.edu.cn 我一开始用的是阿里云的pip源,发现有些模块的版本找不到,就修改成了清华的pip源,最后镜像打成功了,下面是pip国内的一些镜像源 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣(douban) http://pypi.douban.com/simple/ 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
可以通过pip freeze >requirements.txt命令将项目所需模块打包
docker build -t django:latest.
docker run -it -d --restart=always -p 8000:8000 --name django django:latest 命令解释: -d 表示容器在后台运行 –restart=always 表示容器开机自启 -p 表示将容器端口8000映射到主机端口8000上面 –name 表示给容器起的名字
docker打包django项目完成
