方法一:
更换源
RUN sed -i s@/deb.debian.org/@/mirrors.aliyun.com/@g /etc/apt/sources.list \
&& apt-get update
方法二:
RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free" >/etc/apt/sources.list && \
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free" >>/etc/apt/sources.list && \
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free" >>/etc/apt/sources.list && \
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free" >>/etc/apt/sources.list
centos dockerfile 安装Python3.11
# 安装Python3.11依赖
RUN yum -y install gcc zlib zlib-devel libffi libffi-devel
RUN yum -y install bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel xz-devel gdbm-devel
# 安装Python3.11
RUN wget https://mirrors.huaweicloud.com/python/3.11.8/Python-3.11.8.tar.xz
RUN tar -xvf Python-3.11.8.tar.xz
RUN cd Python-3.11.8 && ./configure && make && make install && cd ..
ubuntu dockerfile 安装Python3.11
# 修改镜像源
RUN echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free" >/etc/apt/sources.list && \
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free" >>/etc/apt/sources.list && \
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free" >>/etc/apt/sources.list && \
echo "deb http://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free" >>/etc/apt/sources.list
# 安装Python3.11依赖
RUN apt-get update && apt install wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
# 安装Python3.11
RUN wget https://mirrors.huaweicloud.com/python/3.11.8/Python-3.11.8.tar.xz
RUN tar -xvf Python-3.11.8.tar.xz
RUN cd Python-3.11.8 && ./configure && make && make install && cd ..
Python镜像源: