Docker deploy Python applications

Docker deploy Python applications

1. A single deployment file py

Generate Dockerfile file

Plug with watercress ,, mirror reset time (the time the container is the default UTC time difference between the host and 8 hours).

The context requires three plug-ins (pexpect, pymysql / pywinrm)

Python the FROM: 3.6 

# Set the working directory code folder / App 
WORKDIR / App 
  
# code file to copy the current container / App 
. The ADD / App 

# Set time 
# CentOS 
#UN echo " Asia / shanghai " > / etc / TimeZone; 
# Ubuntu 
RUN cp / usr / report this content share / zoneinfo / Asia / on Shanghai / etc / localtime 


# install the required packages 

RUN PIP install pexpect -i HTTP: // pypi.douban.com/simple/ --trusted-Host pypi.douban. COM 
RUN PIP install pymysql -i HTTP: // pypi.douban.com/simple/ --trusted-Host pypi.douban.com
RUN pip install pywinrm -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com


#RUN \
#apt-get update -y && \
#apt-get install python3-pip -y && \
#pip3 install pexpect && \
#pip3 install pymysql && \
#pip3 install pywinrm && \

 
CMD ["python", "DevOps.py"]

 

 

py file and put the file into the same directory Dockerfile

 

Generate Mirror

docker build -t image name.

 

 

Open container

Set the text:

Container ports: 80

Host machine port: 8031

docker run --name container name -p -d 8031 : 80 image name

 

 

carry out.

 

 

 

 

 

 

Quote: https://www.cnblogs.com/baiboy/p/docker1.html

Quote: https://blog.csdn.net/xin_IT_able/article/details/102840470

Quote: https://www.zixi.org/archives/104.html

 

Guess you like

Origin www.cnblogs.com/1285026182YUAN/p/12171420.html