performance - 在 Travis CI 上缓存 docker 图像

标签 performance caching docker continuous-integration travis-ci

是否可以在 Travis CI 上缓存 docker 图像?尝试使用 travis.yml 中的 cache.directories 缓存 /var/lib/docker/aufs/diff 文件夹和 /var/lib/docker/repositories-aufs 文件似乎不起作用,因为它们需要 root。

最佳答案

从 Docker 的角度来看,我认为最好的方法是 registry (不可能在本地运行网络 save) Docker 镜像并缓存导出的 tar 球。您需要 load在开始时而不是 pull 图像。这样你就不会弄乱 docker 存储实现。

install:
- docker pull busybox
- docker save busybox | gzip > docker/busybox.tar.gz
cache:
  directories:
  - docker

然后您需要在 Travis 运行之前加载缓存的图像。

before_script:
- gzip -dc docker/busybox.tar.gz | docker load

我不清楚 Travis 是否需要在第一次之后停止运行 install 步骤。您不希望 Travis 每次缓存后都提取和导出图像。我不确定是否有 cache 指令会自动为您做到这一点?

那么主要的问题是这是否真的会比拉动图像更快:

The caching tars up all the directories listed in the configuration and uploads them to S3, using a secure and protected URL, ensuring security and privacy of the uploaded archives.

Note that this makes our cache not network-local, it’s still bound to network bandwidth and DNS resolutions for S3. That impacts what you can and should store in the cache. If you store archives larger than a few hundred megabytes in the cache, it’s unlikely that you’ll see a big speed improvement.

您可能只是增加了开销。由于 Docker 注册表由 Cloudfront 提供支持,Travis 已经从本地或至少关闭 Amazon 基础设施中提取压缩图像。也许向他们询问 cache Docker images natively 的功能,类似于他们对 apt 包所做的,although it doesn't sound hopeful .

关于performance - 在 Travis CI 上缓存 docker 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35305492/

相关文章:

python - 在 A[i] 之前的 100 万个项目中,有多少项目小于 A[i]?

r - 求和或矩阵乘法更快吗?

performance - 有没有办法对集合类型进行概率恒定时间相等性检查?

c - C中的空间数据结构

ruby-on-rails - 在 Passenger fork 上重新启动 Rails Redis Cache Store 连接

java - 是否可以仅通过在java客户端中提供缓存配置来启动ignite缓存?

docker - nodemcu Docker构建环境

c - 通过内存访问跟踪文件确定缓存读/写/命中/未命中

docker - 使用不同的后端服务器IP重新加载Haproxy

python - 如何在多阶段 docker 构建期间将 python 从一个阶段复制到另一个阶段