-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cachebeta task: cache base docker image layers #11034
Comments
I would also like a mechanism for speeding up the acquisition of my docker image layers by either using the cache pipeline task or something else. |
FWIW I had started experimenting with this and there are a few options I came across:
|
|
@Rod-Sychev - I'd recommend going the buildctl route. For whatever reason, "docker load" from a local file was slower than doing a pull from a remote registry. If you don't have a private registry and you have super slow-to-run layers (e.g. building lots of native dependencies) then "docker load/save" might still pay off. The challenge with buildctl is getting it installed on the agent. |
@Rod-Sychev btw here's my YML for buildctl tinkering: https://dev.azure.com/codesharing-SU0/cachesandbox/_git/Scripts?path=%2Fdocker.yml&version=GBmaster Here's what I see: Run 1 (Cache Miss) https://dev.azure.com/codesharing-SU0/cachesandbox/_build/results?buildId=16043&view=results
Run 2 (Cache Hit) https://dev.azure.com/codesharing-SU0/cachesandbox/_build/results?buildId=16048&view=logs&j=12f1170f-54f2-53f3-20dd-22fc7dff55f9 Run 3 (Deps hit, src change) https://dev.azure.com/codesharing-SU0/cachesandbox/_build/results?buildId=16049&view=results Not sure why it's taking |
@Rod-Sychev , @ygnr @tjhowse - Can you guys please refer to https://github.com/fadnavistanmay/Scripts/blob/master/docker.yml for caching the docker base image layer Let us know how it goes. |
I have implemented the steps and scripting from the docker.yml file for a .NET Core microservice application, but it doesn't seem to be faster, while caching is used.
|
@stefankip Can you share some YAML and Dockerfile to give some context? |
I'll check if I can create a test scenario somewhere next week... |
So a small update; I've did some testing with an angular project with npm as package manager.
|
Thanks for the tip @stefankip! I've added mode=max to my script. Sounds like 4m30s down to 1m30s sounds like a good improvement! |
Yeah it does. But my .NET Core project didn't have such a performance improvement. I'll do some more tests with that. |
@fadnavistanmay Do you have a docker sample included in your samples repo? |
Good point @johnterickson . Let me add it. |
Sample is added to https://github.com/fadnavistanmay/azure-pipelines-caching-yaml which we will later align with docs |
@johnterickson Thank you. That worked partially for us but in our case, in order to run some integration tests we spin up some dependencies in a docker container (via docker-compose). So these are pulled every time. Any ideas on how can I cache these images? |
@ygnr The hosted agents have no persistent state. The images/layers need to be pulled from somewhere each build (either from Pipeline Caching or else where) |
@johnterickson Is it possible to demonstrate how we can push the built image after it's built from buildctl? We rely on pushing our image to a private registry through an Azure Pipelines service connection |
Yeah I'm struggling with the same thing; getting the resulting image pushed to the ACR. |
So I found out how we can use the created image. |
Can someone explain what the |
Stefan, I'm trying to follow your indications. In this block of code, how should I add those to the docker command?
EDIT:
error: could not read /home/vsts/work/1/buildkitcache/index.json: open /home/vsts/work/1/buildkitcache/index.json: no such file or directory |
Required Information
Question, Bug, or Feature?
Type: Question
Enter Task Name: CacheBeta
Issue Description
Can we use CacheBeta task to cache docker images instead of pulling the images every time? I have tried with cache path set to
/var/lib/docker
on a Hoster Ubuntu Agent. As expected it failed with permission denied. Is there any way to do this or is there any documentation?The text was updated successfully, but these errors were encountered: