江明涛的博客
制做 python docker 镜像
制做 python docker 镜像

制做 python docker 镜像

vim Dockerfile

FROM centos:7
RUN sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' -i.bak /etc/yum.repos.d/CentOS-*.repo
RUN yum makecache
RUN yum update -y
RUN yum install -y zlib-devel bzip2-devel openssl openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel wget net-tools perl
RUN wget https://love.iloveu.website/blog/202207/openssl-1.1.1.tar.gz
RUN tar -zxvf openssl-1.1.1.tar.gz
WORKDIR /openssl-1.1.1
RUN ./config --prefix=/usr/local/openssl shared zlib
RUN make && make install

RUN mv /usr/bin/openssl /usr/bin/openssl.old
RUN mv /usr/lib64/openssl /usr/lib64/openssl.old
RUN mv /usr/lib64/libssl.so /usr/lib64/libssl.so.old
RUN ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
RUN ln -s /usr/local/openssl/include/openssl /usr/include/openssl
RUN ln -s /usr/local/openssl/lib/libssl.so /usr/lib64/libssl.so
RUN echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
RUN ldconfig -v
RUN openssl version

WORKDIR /
RUN wget https://love.iloveu.website/blog/202207/Python-3.9.6.tgz
RUN tar -zxvf Python-3.9.6.tgz
WORKDIR /Python-3.9.6
RUN ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
RUN make && make install

RUN rm -rf /usr/bin/python
RUN rm -rf /usr/bin/pip

RUN sed -i s/python/python2/ /usr/libexec/urlgrabber-ext-down
RUN sed -i s/python/python2/ /usr/bin/yum

RUN ln -s /usr/local/python3/bin/python3.9 /usr/bin/python
RUN ln -s /usr/local/python3/bin/pip3.9 /usr/bin/pip

构建镜像

docker build -t  python396_centos7 .

上传镜像

docker push python396_centos7

上次更新时间 13 3 月, 2023 at 09:59 上午