packer-plugin-docker icon indicating copy to clipboard operation
packer-plugin-docker copied to clipboard

Docker provisioner caching

Open ghost opened this issue 4 years ago • 3 comments

This issue was originally opened by @droopy4096 as hashicorp/packer#9758. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Description

as per issue hashicorp/packer#1995 packer lacks the ability to use Docker cache (or any cache) for image building

Use Case(s)

At the moment I'm refactoring Microsoft Azure Pipeline Agent packer template to build container images (vs VM images) and finding the process to be overly tedious as build itself takes about 30min and with failures happening closer to the end of the build one has to spend extra 30min starting from start instead of recycling what already had been successfully built. There is no way to iterate fast without some sort of caching of all the "good" steps/layers.

Potential configuration

potentially having an option --with-cache=XXX save hashes for each step as tarballs (or other kind of blobs) under the XXX directory, along with the metadata for that step. upon re-run packer should be able to determine existence of cache for each step and use that.

Potential References

ghost avatar Mar 19 '21 12:03 ghost

I don't think this should have been moved here, the Docker builder has perhaps the most expectation of caching, but a solution probably affects/would be for all, since "Packer builds Docker containers without the use of Dockerfiles. By not using Dockerfiles, Packer is able to provision containers with portable scripts or configuration management systems that are not tied to Docker in any way."

I got here by using mkaczanowski/packer-builder-arm and finding it painfully slow to work with/debug due to starting from scratch each time, and thought maybe I could use docker instead. But really I'd rather stick with builder, even if it was just as simple as a temporary --intermediate-caching flag for development, whereby the image is cached between provisioners, so if one fails you can fix it and not have to re-run from scratch.

OJFord avatar Jun 05 '21 14:06 OJFord

Yeah. Lack of caching is the primary reason I stopped using packer. I migrated back to Dockerfile and BuildKit approach.

baryluk avatar Sep 15 '21 14:09 baryluk

any news on this or will this feature never added?

hypery2k avatar Sep 24 '23 07:09 hypery2k