Open MT-Jacobs opened 10 months ago
@MT-Jacobs though its not a solution to the general problem, specific solution for testcontainers is available with the env var TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX
reference
https://java.testcontainers.org/features/image_name_substitution/#automatically-modifying-docker-hub-image-names
https://node.testcontainers.org/features/images/#image-name-substitution
Hope its helps anyone.
This issue is copied from https://github.com/docker/cli/issues/3858, though I included it here because the use case is directly tied to a weakness in this Github Action.
Description
When used locally (in my case, via Docker for Mac), Docker will naturally cache images so they don't have to be repeatedly pulled:
(Notably, the example above, Elasticsearch 8.2.2, is a whopping 1.23GB!)
Some of these cached images are very useful to reuse in builds! For example, the Testcontianers project allows various applications to use Docker containers to act as datastores during testing.
However, when using Docker in a CI platform such as Github Actions, there is no way I've found to cache Docker images through client commands. I found some fantastic examples of how to cache individual Docker layers on build here, but you can only use the build-push action's caching options on
build
, not onpull
.Here is the closest I got using Github Actions as an example - note that the buildx command merely shows the intent of what I'd like to do; it doesn't actually solve the problem I have.
In a perfect world, it would be even better if I could use a Docker CLI command to define a local disk registry that all pulled images should be dumped into; that way there would be a very clear place to cache images to/from.
All that said, is this the right project to make this request? I almost feel like this is a core piece of functionality I just haven't found the right documentation for. That or there's some very good security reason that we don't support this type of caching.