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
As per the Docker Build Push Action docs, setting up the cache-to
and 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?
We faced similar situation some time back but we recently found a github-actions which actually helps in caching the docker-layers & images b/w subsequent runs.
I am sure that your problem can also be solved with it. Here is the link to the gh-action https://github.com/satackey/action-docker-layer-caching.
Configuration Example You can add the following lines above the docker run step to ensure caching to be done in gha
- uses: satackey/[email protected]
continue-on-error: true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With