NVIDIA / enroot

A simple yet powerful tool to turn traditional container/OS images into unprivileged sandboxes.
Apache License 2.0
649 stars 95 forks source link

Image size .sqsh vs .sif #76

Closed bilke closed 3 years ago

bilke commented 3 years ago

This is just a question (no issue):

I build both a .sqsh image file as well as a (Singularity) .sif from the same Docker image. The .sqsh image is almost 3 times the size of the .sif image. What is the reason for this? I played with different compression algorithms but they are all in a similar range.

3XX0 commented 3 years ago

It should be similar even slightly smaller since SIF adds some metadata to the squashfile. Did you make sure they have similar content? Also, try tuning the block size as well as the compression algorithm.

bilke commented 3 years ago

Yes the Docker images are the same.

I could reproduce a similar behavior (.sqsh is double the size of the .sif) with the official Ubuntu image:

$ enroot import -o ubuntu.sqsh docker://ubuntu
$ singularity pull ubuntu.sif docker://ubuntu
...
$ ls -ll
-rwxr-xr-x 1 bilke envinf 27754496 Apr 13 13:05 ubuntu.sif
-rw-r--r-- 1 bilke envinf 53063680 Apr 13 13:03 ubuntu.sqsh

version info:

bilke commented 3 years ago

Increasing the block size helps:

ENROOT_SQUASH_OPTIONS='-b 262144' enroot import -o ubuntu-2x.sqsh docker://ubuntu
...
-rw-r--r-- 1 bilke bilke   27537408 Apr 13 11:13 ubuntu-2x.sqsh
bilke commented 3 years ago

Although the Ubuntu case above is fine, my special use case is still not:

Still the enroot image is roughly 2.5 times the size of the sif image. But if I push the Docker image to an external registry (we use the GitLab registry) and then importing the image back to enroot the resulting .sqsh file is a bit smaller than the sif file as you expected.

Do you have any idea which optimizations / cleanups are done when pushing to an external registry?

3XX0 commented 3 years ago

Um not sure what's going on, they should match. Can you reproduce this with a simple ubuntu image?

bilke commented 3 years ago

Ok got it:

I also set the -noD-option to ENROOT_SQUASH_OPTIONS (because you referenced it here https://github.com/NVIDIA/enroot/issues/6#issuecomment-498868900) which led to the increased image. Omitting that option fixed the size.

Thanks for your help!