Dockerfile-CentOS7.9+Python3.11.2

本文为CentOS7.9下安装Python3.11.2环境的Dockerfile

# CentOS with Python3.11.2
# Author   [email protected]

# build a new image with basic  centos
FROM centos:centos7.9.2009
# who is the author
MAINTAINER [email protected]

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# make a new directory to store the jdk files
RUN mkdir /opt/software \
    && mkdir /usr/local/python3.11.2 \
    && yum -y install vim net-tools telnet tree wget curl \
    && yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel  gcc make libffi-devel -y \
    && yum clean all

# copy the jdk  archive to the image,and it will automaticlly unzip the tar file
ADD Python-3.11.2.tar.gz /opt/software

WORKDIR /opt/software/Python-3.11.2
RUN ./configure --prefix=/usr/local/python3.11.2 --enable-shared CFLAGS=-fPIC \ 
    && make \
    && make install

RUN mv /usr/bin/python /usr/bin/python2 \
    && ln -s /usr/local/python3.11.2/bin/python3 /usr/bin/python \
    && ln -s /usr/local/python3.11.2/bin/pip3 /usr/bin/pip3 \
    && ln -s /usr/local/python3.11.2/bin/pip3 /usr/bin/pip \
    && sed -i '1s/python/python2.7/g' /usr/bin/yum \
    && sed -i '1s/python/python2.7/g' /usr/libexec/urlgrabber-ext-down \
    && touch /etc/ld.so.conf.d/python.conf \
    && echo '/usr/local/python3.11.2/lib' >> /etc/ld.so.conf.d/python.conf \
    && ldconfig

执行

进入dockerfile所在目录
# docker build -t centos7_python3:3.11  .

查看镜像

你可能感兴趣的:(docker,python3.11,docker)