-
Notifications
You must be signed in to change notification settings - Fork 82
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
Hard link disappeared when built docker image #412
Comments
Well at least today (F39) /usr/libexec/git-core/ seems full of symlinks |
The way that the Docker plugin works is that it mounts the image with libguestfs (using FUSE), and then runs tar on the result. However, FUSE, by default, makes up the inodes without regard to the underlying inodes, so tars hardlink detection in tar can't work. There would be two fixes for this: A) pass the use_ino option to the mount call, Something like: diff --git a/imagefactory_plugins/Docker/Docker.py b/imagefactory_plugins/Docker/Docker.py
index 68e12c3..3b44603 100644
--- a/imagefactory_plugins/Docker/Docker.py
+++ b/imagefactory_plugins/Docker/Docker.py
@@ -317,7 +317,7 @@ class Docker(object):
try:
tempdir = tempfile.mkdtemp(dir=storagedir)
self.log.debug("Mounting input image locally at (%s)" % (tempdir))
- guestfs_handle.mount_local(tempdir)
+ guestfs_handle.mount_local(tempdir, options="use_ino")
def _run_guestmount(g):
g.mount_local_run()
self.log.debug("Launching mount_local_run thread")
(not tested since I'm having trouble getting imagefactory to work...) B) Skip the guestmount and use guestfs_tar_out_opts() which would simplify the code quite a bit (no need to start a thread) and likely perform considerably better. The computation of layer size would take a bit of adoption, but I think this is some old obsolete thing - if you use skopeo to copy to 'docker-archive:' you don't get that field. |
Perhaps your one-line patch/workaround could be tested for Fedora Rawhide? |
Copied from https://github.com/containers/toolbox Removed the README.md. See: containers/toolbox#1389 See: https://bugzilla.redhat.com/show_bug.cgi?id=2245066 See: https://pagure.io/releng/issue/11735 See: redhat-imaging/imagefactory#412
When use libguestfs to mount the intermediate image to create a tarball, pass the "use_ino" option so that original inode numbers are preserved. This fixes a problem where hardlinks were not properly preserved in the output. This is a minimal-code-change fix - an edge case bug and better approach are described in comments. Resolves redhat-imaging#412
Turned my pseudo-patch into a a pull request. It's still not actually tested for an image build, but I created a test program to verify the syntax and make sure that it has the intended result. |
After I built a docker image, docker image
tar
file size was more than VM'sraw
disk size :I decompressed docker tar file, and I find that
/usr/libexec/git-core
directory occupied space :Binary files in
/usr/libexec/git-core
directory were almost hard link.The text was updated successfully, but these errors were encountered: