Cache interaction is broken when building images via podman build --omit-history.
New layers don't end up in the cache, and existing layers are reused including their history.
Steps to reproduce the issue
$ printf 'FROM docker.io/library/alpine:3.18\nRUN date' | podman build --omit-history -
STEP 1/2: FROM docker.io/library/alpine:3.18
Trying to pull docker.io/library/alpine:3.18...
Getting image source signatures
Copying blob 96526aa774ef skipped: already exists
Copying config 8ca4688f4f done |
Writing manifest to image destination
STEP 2/2: RUN date
Tue Nov 21 15:32:52 UTC 2023
COMMIT
--> f7e920a5e917
f7e920a5e9171144da5797b109a2c136cfcb9c3d25570a2e15238ddccd18be18
$ printf 'FROM docker.io/library/alpine:3.18\nRUN date' | podman build --omit-history -
STEP 1/2: FROM docker.io/library/alpine:3.18
STEP 2/2: RUN date
Tue Nov 21 15:32:54 UTC 2023
COMMIT
--> 285f5f14252c
285f5f14252cee7d3eb88f75957adac208528a5471d17b40705ee4b1d2b010fa
$ printf 'FROM docker.io/library/alpine:3.18\nRUN date' | podman build --omit-history -
STEP 1/2: FROM docker.io/library/alpine:3.18
STEP 2/2: RUN date
Tue Nov 21 15:32:57 UTC 2023
COMMIT
--> ee3af5ae117e
ee3af5ae117efefe9b334b4e2cbad23ffb92879b93e8a794c6e3bfb54a5977af
$ podman inspect ee3af5ae117efefe9b334b4e2cbad23ffb92879b93e8a794c6e3bfb54a5977af | jq '.[0].History'
null
$ printf 'FROM docker.io/library/alpine:3.18\nRUN date' | podman build -
STEP 1/2: FROM docker.io/library/alpine:3.18
STEP 2/2: RUN date
Tue Nov 21 15:33:03 UTC 2023
COMMIT
--> 4b4fcc775992
4b4fcc775992121e70781051b7b294ee8b175bd24672b6c632131f03f81c7f8d
$ printf 'FROM docker.io/library/alpine:3.18\nRUN date' | podman build -
STEP 1/2: FROM docker.io/library/alpine:3.18
STEP 2/2: RUN date
--> Using cache 4b4fcc775992121e70781051b7b294ee8b175bd24672b6c632131f03f81c7f8d
--> 4b4fcc775992
4b4fcc775992121e70781051b7b294ee8b175bd24672b6c632131f03f81c7f8d
$ printf 'FROM docker.io/library/alpine:3.18\nRUN date' | podman build --omit-history -
STEP 1/2: FROM docker.io/library/alpine:3.18
STEP 2/2: RUN date
--> Using cache 4b4fcc775992121e70781051b7b294ee8b175bd24672b6c632131f03f81c7f8d
--> 4b4fcc775992
4b4fcc775992121e70781051b7b294ee8b175bd24672b6c632131f03f81c7f8d
$ podman inspect 4b4fcc775992121e70781051b7b294ee8b175bd24672b6c632131f03f81c7f8d | jq '.[0].History'
[
{
"created": "2023-09-28T21:19:27.686110063Z",
"created_by": "/bin/sh -c #(nop) ADD file:756183bba9c7f4593c2b216e98e4208b9163c4c962ea0837ef88bd917609d001 in / "
},
{
"created": "2023-09-28T21:19:27.801479409Z",
"created_by": "/bin/sh -c #(nop) CMD [\"/bin/sh\"]",
"empty_layer": true
},
{
"created": "2023-11-21T15:33:04.000783167Z",
"created_by": "/bin/sh -c date",
"comment": "FROM docker.io/library/alpine:3.18"
}
]
Describe the results you received
When starting a fresh image build using --omit-history, everything works, but the layer cache won't get populated. I verified this by running the same command multiple times. Doing the same thing without the --omit-history flag yields a cache hit on the second invocation. Funnily enough, a subsequent invocation including the --omit-history flag now has cache hits as well, but this time, the images actually include the history.
Describe the results you expected
Proper caching for builds, no matter if they're using --omit-history or not.
No history for images built with --omit-history, no matter what.
Issue Description
Cache interaction is broken when building images via
podman build --omit-history
.New layers don't end up in the cache, and existing layers are reused including their history.
Steps to reproduce the issue
Describe the results you received
When starting a fresh image build using
--omit-history
, everything works, but the layer cache won't get populated. I verified this by running the same command multiple times. Doing the same thing without the--omit-history
flag yields a cache hit on the second invocation. Funnily enough, a subsequent invocation including the--omit-history
flag now has cache hits as well, but this time, the images actually include the history.Describe the results you expected
--omit-history
or not.--omit-history
, no matter what.podman info output
Podman in a container
No
Privileged Or Rootless
Rootless
Upstream Latest Release
Yes
Additional environment details
NixOS 23.05. System on commit 9fb1225, using the podman binary from current master (9075a0d).
Additional information
Using caches with history for builds using
--omit-history
seems reasonable, but the history would need to be stripped afterwards, of course.