docker

docker使用centos镜像部署flask

首先,我们创建一个支持SSH的centos7镜像
创建Dockerfile,内容如下:

FROM        centos:7
MAINTAINER  dys "dys@abc.com"
RUN         yum install -y openssh openssh-server openssh-clients
RUN         mkdir -p /var/run/sshd
RUN         ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
RUN         ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
RUN         /bin/echo 'root:aaaaaa' |chpasswd
RUN         useradd dys
RUN         /bin/echo 'dys:aaaaaa' |chpasswd
RUN         /bin/sed -i 's/.*session.*required.*pam_loginuid.so.*/session optional pam_loginuid.so/g' 
/etc/pam.d/sshd
RUN         /bin/echo -e "LANG=\"en_US.UTF-8\"" > /etc/default/local
EXPOSE      22
CMD         /usr/sbin/sshd -D

创建镜像

docker build -t centos7ssh .

然后创建支持python环境的镜像

# Using Centos for base image
FROM centos7ssh
# author label
LABEL maintainer="Aron.li"

# install timezone gcc
ENV ENVIRONMENT DOCKER_PROD
RUN cd / && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& yum makecache \
&& yum install -y wget aclocal automake autoconf make gcc gcc-c++ python-devel mysql-devel bzip2 
libffi-devel epel-release \
# install python 3.7.1
&& wget https://npm.taobao.org/mirrors/python/3.7.1/Python-3.7.1.tar.xz \
&& tar -xvf Python-3.7.1.tar.xz -C /usr/local/ \
&& rm -rf Python-3.7.1.tar.xz \
&& cd /usr/local/Python-3.7.1 \
&& ./configure && make && make install \
# install pip3
&& yum install -y python-pip \
&& yum install -y python-setuptools \
&& pip3 install --upgrade pip -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com \
&& pip3 install setuptools==33.1.1 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com \
&& yum clean all

# copy project
COPY . /project

创建名为pythonenv的镜像

docker build -t pythonenv .

回复

This is just a placeholder img.