Skip to content
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

[Feat] Add commit compression type support #4061

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lengrongfu
Copy link

@lengrongfu lengrongfu commented Mar 31, 2025

Fix #4060

Use zstd compression can shorten commit time. current containerd v2 having support zstd commit type, but containerd v1 version don't support.

Test case:

  1. create nginx pod, write a 5G file.
#!/bin/sh
for ((i=1; i<=5; i++))
do
  dd if=/dev/urandom of=$i".txt" bs=500M count=2
done
  1. use zstd compression to commit container only need 29s time.
$ nerdctl -n k8s.io commit ca45e0595384b14ee1fbef6f0a38efb2a2725471cb8fc143d9720a068d8b6cb1 easzlab.io.local:5000/demo/nginx:v2 --pause=true --compression=zstd

image

to view blob type.

$ nerdctl -n k8s.io image inspect --mode=native easzlab.io.local:5000/demo/nginx:v2

image

  1. use gzip compression to commit container need 2m5s time.
$ nerdctl -n k8s.io commit ca45e0595384b14ee1fbef6f0a38efb2a2725471cb8fc143d9720a068d8b6cb1 easzlab.io.local:5000/demo/nginx:v3 --pause=true

image

@apostasie
Copy link
Contributor

CI is failing right now - bustage will be fixed by #4058

@@ -759,6 +759,7 @@ Flags:
- :whale: `-m, --message`: Commit message
- :whale: `-c, --change`: Apply Dockerfile instruction to the created image (supported directives: [CMD, ENTRYPOINT])
- :whale: `-p, --pause`: Pause container during commit (default: true)
- :whale: `--compression`: Commit compression algorithm,(supported value: zstd or gzip) (default: gzip)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Docker have this? If not this has to be :nerd_face:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.docker.com/reference/cli/docker/container/commit/

Docker current is not support. @thaJeztah Not sure if I can consult you? Will docker commit add this feature?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @lengrongfu ,
If it's nerd_face, it can be changed to

- :nerd_face: `--compression`: Commit compression algorithm,(supported value: zstd or gzip) (default: gzip)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update done.

func createDiff(ctx context.Context, name string, sn snapshots.Snapshotter, cs content.Store, comparer diff.Comparer, compression string) (ocispec.Descriptor, digest.Digest, error) {
opts := make([]diff.Opt, 0)
mediaType := images.MediaTypeDockerSchema2LayerGzip
if compression == "zstd" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should raise an error if the string is invalid

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add verify this field compression value whether is gzip or zstd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

container commit use compression type,eg zstd, gzip
4 participants