docker - 如何删除 Travis CI 上的缓存?

标签 docker caching travis-ci

我在 travis-ci 上缓存了一个 docker 镜像。 docker 镜像是从 dockerfile 创建的。现在我的 dockerfile 发生了变化,我需要删除缓存并重建 docker 镜像。如何删除 travis-ci 上的缓存?

我当前的 .travis.yml 如下所示:

language: C
services:
- docker
cache:
  directories:
  - docker_cache
before_script:
- |
  echo Now loading...
  filename=docker_cache/saved_images.tar
  if [[ -f "$filename" ]]; then
    echo "Got one from cache."
    docker load < "$filename"
  else
    echo "Got one from scratch";
    docker build -t $IMAGE .
    docker save -o "$filename" $IMAGE 
  fi
script:
- docker run -it ${IMAGE} /bin/bash -c "pwd"
env:
- IMAGE=test04

最佳答案

the docs共有三种方法:

  • 使用用户界面:存储库页面上的“更多选项”->“缓存”
  • 使用 CLI:travis cache --delete
  • 使用API :删除/repos/{repository.id}/caches

也就是说,Docker 镜像是明确称为 thing not to cache 的示例之一。 :

Large files that are quick to install but slow to download do not benefit from caching, as they take as long to download from the cache as from the original source

在您的示例中,不清楚 Dockerfile 之外的管道中涉及哪些内容 - 即使文件本身没有更改,任何进入其中的内容(基本镜像、源代码、等)可能有。缓存图像意味着您可能会得到误报,即使 docker build 会失败,构建也会通过。

关于docker - 如何删除 Travis CI 上的缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66709707/

相关文章:

ruby-on-rails - dotenv 是否会覆盖 docker compose 设置的环境变量?

c++ - curl_slist_free_all() 在带有 Debian 8.7 的 GKE 上导致段错误

nginx - Owncloud 8 with Docker behind nginx 可通过子目录获得

ios - 将 UIWebView 的(通过 Web 服务加载)<img> 标记源替换为本地(缓存)源

android - 无法使用 avdmanager 创建 Travis CI android 模拟器

python - 在 Travis CI 中自动构建 Mkdocs 文档

docker - Flink 1.2.1-当Flink在容器中运行时,如何创建保存点?

apache - 在 Web 服务器中实现 HTTP ETag

ruby-on-rails - 何时在 Rails 3 中使用虚拟属性或以散列形式传递数据

travis-ci - 我可以将matrix.include[]中的选项与env选项相乘吗?