编写Dockerfile文件运行django项目
文件内容:
FROM: python:3.6 # 设置编码 ENV LANG en_US.UTF-8 #ENV TZ=Asia/Shanghai #RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # 1. 安装基本依赖 #RUN yum update -y && yum install epel-release -y && yum update -y && yum install wget unzip epel-release nginx xz gcc automake zlib-devel openssl-devel supervisor groupinstall development libxslt-devel libxml2-devel libcurl-devel git -y #WORKDIR /var/www/ RUN mkdir -p /app/ WORKDIR /app/ ADD /app/cdata/ /app/cdata/ RUN cd /app/cdata/ RUN pip3 install -r /app/cdata/requirements.txt EXPOSE 8000 CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
构建镜像:
docker build -f Dockerfile -t cdata_img/py3.6:v1
docker运行:
docker run -it -d -p 9111:8000 cdata_img/py3.6:v1
通过 ip:9111访问服务。
end~