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

support docker commit #1370

Open
ghost opened this issue Sep 7, 2023 · 7 comments
Open

support docker commit #1370

ghost opened this issue Sep 7, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Sep 7, 2023

Support packing writable layer of an existing container into sgz blob format. this may be very useful for migrating containers across machines.

See also containerd/nydus-snapshotter#232

@dmosdallas
Copy link

This is an idea that I'm very interested in as well.

With the stargz-snapshotter configured & running a container that is already formatted in eStargz, I can run a docker commit and have it create a new image that retains the eStargz-format for the base layers, but not for the newly-created one.

If I'm understanding correctly, you're asking for the newly-committed layer to also be in eStargz format?

@ktock
Copy link
Member

ktock commented Sep 20, 2023

As of now you can do something like the following for converting the commited image but yes it would be great if docker commit natively support this.

cat <<EOF | docker buildx build -t newimage -o ...(omit)...compression=estargz,force-compression=true -f - /tmp/emptydir
FROM your-commited-image
EOF

@dmosdallas
Copy link

@ktock, yep! I was just trying out this approach and it sort-of works. Two things I've noticed:

  1. The committed image needs to be pushed to my repo. For some reason, the buildx builder is unable to find the committed image if it's just stored locally. Not a huge deal to me, I'm assuming it's another issue of the flavor of docker & stargz-snapshotter looking at different local repos?
  2. Repeatedly doing this trick fails. To reproduce:
    a. Create a new estargz image.
    b. Run a container using that image.
    c. Run docker commit && docker push && docker buildx build to create a new estargz-formatted image using the newly-committed content.
    d. Launch a new container using the new image created in c.
    e. Attempt doing (c.) with this new container. During the docker push, I get an error like: content digest sha256:4995b2a4e3208e54e262024d707e4ef39a4ee0f8b3aaf277c3ffb7c81bd592ce: not found

@dmosdallas
Copy link

Should have mentioned, when I do an inspect on the image I'm trying to push in 2e., no layer has the digest that it's complaining about.

@dmosdallas
Copy link

I've been investigating this more today and I think a docker commit with the stargz-snapshotter is less functional than I originally thought.

When I do a docker commit on a container that was launched using this snapshotter, the full container is pulled down as part of the commit process. Is that how it is currently expected to work? I'm not familiar enough with the internals of how a docker commit pulls a container's base layers vs how a docker run does to understand if this discrepancy is surprising.

If this is currently working as expected, is it clear how much effort would be required to teach docker commit to use this snapshotter instead of pulling the full base image? And if this is reasonably well-scoped, I'd be happy to contribute work to make this functional.

Thanks!

@ktock
Copy link
Member

ktock commented Sep 22, 2023

@dmosdallas

If this is currently working as expected, is it clear how much effort would be required to teach docker commit to use this snapshotter instead of pulling the full base image? And if this is reasonably well-scoped, I'd be happy to contribute work to make this functional.

Thanks. Though I haven't look deeper into docker's implementation of commit, I guess first we need to make sure that creating the uppermost layer tarball from the written container doesn't cause full scan on the rootfs data. IIRC the default layer creation logic (differ) of containerd is that it compares the entier rootfs contents between the old image and the updated container and it can cause large download of the rootfs data. Rather than fully-comparing the rootfs contents, we should create the uppermost layer tarball simply from the overlayfs upperdir written by the container if stargz-snapshotter or other overlayfs-based snapshotter is used (this is how BuildKit achieve layer creation without fully downloading the base image contents).

@ktock ktock added the enhancement New feature or request label Sep 22, 2023
@ghost
Copy link
Author

ghost commented Oct 21, 2023

we should create the uppermost layer tarball simply from the overlayfs upperdir written by the container if stargz-snapshotter or other overlayfs-based snapshotter is used

will this be supported soon?

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

No branches or pull requests

2 participants