Dockerfile技巧

换镜像源

Ubuntu

RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list

Alpine

RUN sed -i 's/http:\/\/dl-cdn.alpinelinux.org/https:\/\/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories

移除软件包缓存

Ubuntu

RUN rm -vrf /var/lib/apt/lists/*

Alpine

RUN rm -vrf /var/cache/apk/* && \
    rm -vrf /var/lib/apk/* && \
    rm -vrf /etc/apk/cache/*

猜你喜欢

转载自www.cnblogs.com/zhuxiaoxi/p/9356386.html