cover

基于Centos7的Python3.7镜像构建

Dockerfile

FROM centos:7

MAINTAINER linvaux <[email protected]>

WORKDIR /opt

RUN sed -i "s/#baseurl/baseurl/g" /etc/yum.repos.d/CentOS-Base.repo && \
    sed -i "s/mirrorlist=http/#mirrorlist=http/g" /etc/yum.repos.d/CentOS-Base.repo && \
    sed -i "s@http://mirror.centos.org@https://repo.huaweicloud.com@g" /etc/yum.repos.d/CentOS-Base.repo && \
		yum clean all && \
    yum makecache && \
    yum update -y

RUN yum install -y wget zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make

RUN wget https://mirrors.huaweicloud.com/python/3.7.8/Python-3.7.8.tgz && \ 
    tar -vxf Python-3.7.8.tgz && \
    mv Python-3.7.8 /usr/local/python378 && \
    cd /usr/local/python378 && \
    ./configure --prefix=/usr/local/python378 --enable-loadable-sqlite-extensions --with-ssl &&\
    make -j$(nproc) && \
    make install -j$(nproc) && \
    ln -s /usr/local/python378/bin/python3.7 /usr/bin/python3 && \
	  ln -s /usr/local/python378/bin/pip3 /usr/bin/pip3 && \
    mkdir /root/.pip && \
    echo "[global]" > /root/.pip/pip.conf && \
    echo "index-url=https://pypi.douban.com/simple/" >> /root/.pip/pip.conf && \
    echo "[install]" >> /root/.pip/pip.conf && \
    echo "trusted-host=pypi.douban.com" >> /root/.pip/pip.conf
RUN rm -rf Python-3.7.8.tgz

构建命令

docker build -t centos-python378 .
博客已迁移至:https://linvaux.github.io/
加入