RUNsed-i's/security.debian.org/mirrors.ustc.edu.cn/g'/etc/apt/sources.list 保存并构建Docker镜像,您的Dockerfile中的 apt-get 命令将使用中国国内源。 请注意,使用国内源可能会对软件包的可用性和稳定性产生一些影响。建议在更改源之前先测试您的Docker镜像,以确保所有依赖项都可用。 这个命令使用sed(流编...
下面我们将通过一个简单的Dockerfile示例来演示如何更换Debian的apt安装源。 #使用Debian作为基础镜像FROM debian#安装wget工具RUN apt-get update && apt-get install -y wget#下载国内镜像源的配置文件RUN wget -O /etc/apt/sources.list#更新apt软件包索引RUN apt-get update#安装需要的软件包RUN apt-get insta...
FROM python:3.7.0RUN sed -i s/deb.debian.org/mirrors.aliyun.com/g /etc/apt/sources.list RUN apt-get cleanRUN apt-get update RUN apt-get update && apt-get install -y libsasl2-dev python-dev libldap2-dev libssl-dev COPY ./requirements.txt / RUN pip3 install --upgrade pip RUN pi...
修改Debian源 要修改Debian源,我们可以在Dockerfile中添加一行sed命令来替换/etc/apt/sources.list文件中的源地址。下面是修改后的Dockerfile示例: FROMdebian:latestRUNsed -i's/http:\/\/deb.debian.org\/debian\//http:\/\/mirrors.ustc.edu.cn\/debian\//g'/etc/apt/sources.list &&\apt-get update &...
加个RUN, 修改 /etc/apt/sources.list 就阔以了呀。 sed, echo什么的
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list && \ sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list && \ apt-get update && \ apt-get install -y unzip && \ unzip test.zip -d dist...
FROM ubuntu:20.04# 获取 ubuntu:20.04镜像ENV DEBIAN_FRONTEND=noninteractive# 环境变量ENV LANG C.UTF-8# 环境变量RUN sed -i 's@http://archive.ubuntu.com/ubuntu/@http://mirrors.aliyun.com/ubuntu/@g' /etc/apt/sources.list# 更换源RUN apt-getupdate-qq# apt-get update && install operationRUN...
1FROMdebian:stretch23RUNbuildDeps='gcc libc6-dev make wget'\4&&apt-getupdate \5&&apt-getinstall-y $buildDeps \6&&wget-Oredis.tar.gz"http://download.redis.io/releases/redis-5.0.3.tar.gz"\7&&mkdir-p/usr/src/redis \8&&tar-xzf redis.tar.gz-C/usr/src/redis--strip-components=1\9...
#因为官方镜像是用的debain stretch 所以第一步先替换源 如果是Jessie 要替换对应的源 RUN echo "deb http://mirrors.aliyun.com/debian stretch main contrib non-free" > /etc/apt/sources.list && \ echo "deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free" >> /etc/apt/sou...
RUN 指令最常见的用法是安装包用的apt-get,因为该指令会安装包,所以有几个问题需要注意。 不要使用RUN apt-get upgrade 或 dist-upgrade, 如果基础镜像中的某个包过时了,你应该联系它的维护者。 如果你确定某个特定的包比如 foo 需要升级,使用apt-get install -y foo就行,该指令会自动升级 foo 包。