Docker 操作:基于 Centos7 构建 python3 镜像

 这里有个坑,在 centos 中配了 python3 之后,yum 命令所依赖的 python2.7 会报错,需要专门配一下

FROM centos:centos7

RUN yum update -y
RUN set -ex \
	&& yum -y install zlib-devel bzip2-devel libffi-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make wget \
	&& yum clean all \
	&& wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz \
	&& mkdir /usr/local/python3 \
    && cp Python-3.9.0.tgz  /usr/local/python3/ 
RUN set -ex \
	&& cd /usr/local/python3 \
	&& tar -zxvf Python-3.9.0.tgz \
	&& cd Python-3.9.0 \
	&& ./configure prefix=/usr/local/python3 \
	&& make && make install \
	&& make clean \
    && yum install -y epel-release \
    && yum install -y python-pip
RUN set -ex \
    && mv /usr/bin/python /usr/bin/python27 \
    && mv /usr/bin/pip /usr/bin/pip-python2.7 \
	&& ln -s /usr/local/python3/bin/pyt

你可能感兴趣的:(Docker,centos,python,docker)