您正在考虑使用squid 代理
吗?
编辑:如果你不想去上面的官方网站,这里是 squid 代理的快速设置(基于 debian)
apt-get install squid-deb-proxy
然后通过open up改变squid配置以创造更大的空间
/etc/squid/squid.conf
然后替换#cache_dir ufs /var/spool/squid为cache_dir ufs /var/spool/
squid 10000 16 256
10.000 MB 的缓存空间
然后在dockerfile中指向代理地址,这里是dockerfile和squid代理的例子
基于 yum 和 apt-get 的发行版:
基于 apt-get 的发行版
`FROM debian
RUN apt-get update -y && apt-get install net-tools
RUN echo "Acquire::http::Proxy \"http://$( \
route -n | awk '/^0.0.0.0/ {print $2}' \
):8000\";" \ > /etc/apt/apt.conf.d/30proxy
RUN echo "Acquire::http::Proxy::ppa.launchpad.net DIRECT;" >> \
/etc/apt/apt.conf.d/30proxy
CMD ["/bin/bash"]`
基于百胜的发行版
`FROM centos:centos7
RUN yum update -y && yum install -y net-tools
RUN echo "proxy=http://$(route -n | \
awk '/^0.0.0.0/ {print $2}'):3128" >> /etc/yum.conf
RUN sed -i 's/^mirrorlist/#mirrorlist/' \
/etc/yum.repos.d/CentOS-Base.repo
RUN sed -i 's/^#baseurl/baseurl/' \
/etc/yum.repos.d/CentOS-Base.repo
RUN rm -f /etc/yum/pluginconf.d/fastestmirror.conf
RUN yum update -y
CMD ["/bin/bash"]`
假设您在 aws 注册表中安装 squid 代理,只有第一个构建会从 Internet 获取数据,其余(另一台服务器)构建应该来自缓存的 squid 代理。.
此技术基于 book docker in practice技术 57 with title设置包缓存以加快构建速度
我认为没有任何第三方软件的 docker 中没有缓存功能。也许有,但我只是不知道。.im不确定,如果我错了,请纠正我。.