安装完成后已将python3设置为默认python环境
dockerFile内容如下:
FROM centos:7.6.1810
ENV PATH $PATH:/usr/local/python3/bin/
ENV PYTHONIOENCODING utf-8
RUN echo 'nameserver 8.8.8.8\n \
nameserver 114.114.114.114\n' \
>> /etc/resolv.conf
RUN set -ex \
&& mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup \
&& curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo \
&& yum makecache \
&& sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo \
&& yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make wget \
&& yum clean all \
&& mkdir /usr/local/python3 \
&& wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz \
&& tar -xvJf Python-3.6.8.tar.xz && rm -f Python-3.6.8.tar.xz \
&& cd Python-3.6.8 \
&& ./configure prefix=/usr/local/python3 \
&& make && make install \
&& cd .. \
&& rm -rf Python-3.6.8 \
&& cd /usr/local/python3 \
&& mv /usr/bin/python /usr/bin/python.bak \
&& ln -s /usr/local/python3/bin/python3.6 /usr/bin/python \
&& ln -s /usr/local/python3/bin/pip3 /usr/bin/pip \
&& python -m pip install --upgrade pip \
CMD ["usr","bin","bash"]