buildah icon indicating copy to clipboard operation
buildah copied to clipboard

[FEATURE REQUEST] Allow pushing uncompressed images to local docker registry

Open fruttasecca opened this issue 2 years ago • 29 comments

This is currently not possible given that the desired compression is hardcoded in vendor/github.com/containers/image/v5/docker/docker_image_dest.go, which leads to ignoring the --disable-compression flag on push.

func (d *dockerImageDestination) DesiredLayerCompression() types.LayerCompression {
	return types.Compress
}

FYI, I have tried to set it to types.PreserveOriginal and rebuilt buildah, which appears to work.

fruttasecca avatar Apr 07 '22 07:04 fruttasecca

Hi @fruttasecca Thanks for opening the issue. This looks like a nice feature request, I'll try checking this.

flouthoc avatar Apr 07 '22 10:04 flouthoc

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar May 08 '22 00:05 github-actions[bot]

@mtrmac @vrothberg PTAL

rhatdan avatar May 09 '22 14:05 rhatdan

Yes, this should be easily possible by making that an option in c/image/types.SystemContext, having dockerImageDestination.DesiredLayerCompression make a decision based on that option, and then hooking that option up to the Buildah/Podman CLI.

I’m afraid it’s not something I’m likely to work on any time soon. Care to prepare PRs?

mtrmac avatar May 09 '22 16:05 mtrmac

As long as its possible, @flouthoc could you look into this?

rhatdan avatar May 09 '22 18:05 rhatdan

Actually… @fruttasecca Why do you want this to be possible?

mtrmac avatar May 09 '22 19:05 mtrmac

I'll take a look at this just waiting for @mtrmac 's concern to be answered.

flouthoc avatar May 10 '22 04:05 flouthoc

Hi @mtrmac, essentially we are in a situation of limited vcpus, images having a size of a few gigs (unbound since users are allowed to add more) and a registry that is deployed in the same cluster as the buildah pod. We favoured speed over space, pushing with types.PreserveOriginal allowed us to reduce the total build+push time by almost 50%.

fruttasecca avatar May 11 '22 13:05 fruttasecca

Thanks, that makes sense.

(Often enough, these flag requests are motivated, after digging 3-4 steps deep, by some completely unrelated bug or missing feature, so I think it’s always worth asking.)

mtrmac avatar May 11 '22 17:05 mtrmac

Makes sense, thank you for looking into it :+1: .

fruttasecca avatar May 12 '22 07:05 fruttasecca

@flouthoc Looks like we are a go.

rhatdan avatar May 12 '22 20:05 rhatdan

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Jun 12 '22 00:06 github-actions[bot]

We'd be happy to contribute to help get this feature over the line. Anything in particular the core team is still thinking about in relation to this being added?

We're now maintaining a patched fork which is a bit cumbersome with multi-arch CI.

Thanks for building an awesome tool 🙏

ricklamers avatar Jun 30 '22 16:06 ricklamers

@ricklamers Sure, would you like to share the patch or create PR if possible ? Otherwise i'll try to get this in coming days.

flouthoc avatar Jun 30 '22 16:06 flouthoc

@ricklamers @fruttasecca Could you also help me know how are you testing this ? I see no difference in the size of pushed blobs/layers i am testing this by pusing to dockerhub ( tried both --format docker and --format oci )

func (d *dockerImageDestination) DesiredLayerCompression() types.LayerCompression {
-	return types.Compress
+	return types.PreserveOriginal
} 

if you have a patch in handy could you please share it.

flouthoc avatar Jul 05 '22 03:07 flouthoc

Hi @flouthoc, thanks for looking into it. We are building buildah 1.26 from this branch https://github.com/orchest/buildah/tree/experimental/1.26.0-no-docker-registry-compression. This (https://github.com/containers/buildah/commit/fe6b5ad0ef60af65f82306b8a580e32003eb1ade) is the only change we needed to do, and this is how we build the image https://github.com/orchest/buildah/blob/experimental/1.26.0-no-docker-registry-compression/Dockerfile.

This is how we are running the CLI in a pod, pushing to a docker registry deployed in a k8s cluster, not dockerhub (this is an interpolated & multiline python string)

# Build
f"buildah build -f {dockerfile_path} --layers=true "
# Package managers caches.
# jovyan is the user of the base image.
"-v /pip-cache:/home/jovyan/.cache/pip "
# Obtained by running "conda info". Note
# that this cache is also used by mamba.
"-v /conda-cache:/opt/conda/pkgs "
# https://github.com/containers/buildah/issues/2741
"--format docker "
"--force-rm=true "
"--disable-compression=true "
# Avoid a warning about not being able
# to write to the audit log.
"--cap-add=CAP_AUDIT_WRITE "
f"--tag {full_image_name} "
# Push
"&& buildah push "
"--disable-compression=true "
# Buildah might compress regardless of
# the specified options depending on the
# destination storage, tune such
# compression.
"--compression-format=zstd:chunked "
"--compression-level=0 "
f"{full_image_name}"

About disabling compression, it's not a hard requirement but more like something that we had to do to reduce cpu overhead in a context of limited resources. Happy to go through some more benchmarking and playing around with --flags in the future to see where/if the sweet spot has moved with new buildah releases.

fruttasecca avatar Jul 05 '22 07:07 fruttasecca

I see no difference in the size of pushed blobs/layers i am testing this by pusing to dockerhub

Are the blobs actually being pushed? See the debug log; you might need to delete the blob info cache, otherwise the push code will know that there is already a version on the registry, and prefer that one regardless of DesiredLayerCompression.

mtrmac avatar Jul 05 '22 14:07 mtrmac

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Aug 05 '22 00:08 github-actions[bot]

Since you never answered @mtrmac I am going to assume you have this working. Closing. Reopen if you have more feedback or this issue is ongoing.

rhatdan avatar Aug 07 '22 10:08 rhatdan

I see no difference in the size of pushed blobs/layers i am testing this by pusing to dockerhub

Are the blobs actually being pushed? See the debug log; you might need to delete the blob info cache, otherwise the push code will know that there is already a version on the registry, and prefer that one regardless of DesiredLayerCompression.

Whoops this was a question for me and not for the issue author so issue is still not resolved, just re-opening. :)

flouthoc avatar Aug 08 '22 07:08 flouthoc

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Nov 17 '22 00:11 github-actions[bot]

@flouthoc any progress?

rhatdan avatar Nov 18 '22 20:11 rhatdan

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Dec 20 '22 00:12 github-actions[bot]

@flouthoc any progress?

rhatdan avatar Dec 22 '22 13:12 rhatdan

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Jan 23 '23 00:01 github-actions[bot]

Is there anyone still working on this?

ryeyao avatar May 10 '23 13:05 ryeyao

@ryeyao No but I'll take a look thanks for the poke.

flouthoc avatar May 10 '23 14:05 flouthoc

Anyone working on this?

alexdmiller avatar Jan 24 '24 20:01 alexdmiller

Doubt it. @flouthoc is off working on his graduate degree, so the Buildah project could use more help.

rhatdan avatar Jan 24 '24 21:01 rhatdan