On Github Actions, I’d like to avoid having to pull my newly built Docker image from the registry when I have it in a cache (and this is the slowest part of my jobs)
My workflow is something like
- Build an image (with all my dependencies baked in)
- Run a command within the above image
As per the Docker Build Push Action docs, setting up the
cache-from to point to
gha has helped speed up step 1 a lot.
However, when I run
docker run ghcr.io/org/image:new-tag command, it always starts with
Unable to find image 'ghcr.io/org/image:new-tag' locally new-tag: Pulling from org/image ... 5402d6c1eb0a: Pulling fs layer ...
which takes around a 50 seconds (of around a total job time of ~75 seconds).
This seems unnecessary when there’s a cache sat within reach that contains this information, however I don’t know how to tell my
docker run command how to make use of this cache as, as far as I can see, there’s no
--cache-from=gha equivalent option for docker run.
How can I tell docker to look in the gha cache for an image when I call docker run on Github Actions?
Source: Docker Questions