Contents

基于centos Docker配置python生产环境

未使用docker file

新建容器,基于centos 7

docker run -d -it -p 8889:80 -v /var/pyapi/code_data/:/code_data -v /var/pyapi/config/:/var/config -v /var/pyapi/log:/var/log --name rechao_pyapi centos:7.4.1708

进入docker

dcoker exec -it {container_name} bash

下载文件

安装wget yum install -y wget

安装依赖配置yum install -y make pcre pcre-devel zlib zlib-devel openssl openssl-devel

nginx: wget http://nginx.org/download/nginx-1.17.1.tar.gz

Python v=3.6.5;wget http://mirrors.sohu.com/python/$v/Python-$v.tar.xz

解压文件&安装 nginx pyton supervisor

tar -zxvf nginx-1.17.0.tar.gz

./configure

安装make && make install

建立软连接

ln -s /usr/local/bin/python3.6 /usr/bin/python3

新建entrypoint

#!/bin/bash

nginx
supervisord -c /etc/supervisor.conf

while [ 1 = 1 ]

do

sleep 1;

done
tail -f /dev/null

启动nginx

/usr/local/nginx/sbin/nginx

检测nginx状态:http://{your ip}:{docker port}/

建立新镜像

docker commit -a "teaser" -m "rechao python web api" rechao_pyapi rechao_pyapi:0.3

修改配置文件

推送到doker 仓库