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

RFE: singularity shrink #623

Closed
akkornel opened this issue Apr 21, 2017 · 1 comment
Closed

RFE: singularity shrink #623

akkornel opened this issue Apr 21, 2017 · 1 comment

Comments

@akkornel
Copy link
Contributor

When I am bootstrapping a container, I'm never too sure how big that container image needs to be. However, once I'm done bootstrapping it, I should never need to make changes to it.

It would be nice to have a singularity shrink command, which will shrink a container image to its smallest size.

It's actually possible to do this in shell today, with something like this script:

image=PATH_TO_IMAGE
stripped_img=`tempfile --directory=.`
tail -n +2 $image > $stripped_img
e2fsck -f $stripped_img
resize2fs -M $stripped_img
shrunk_img=`tempfile --directory=.`
head -n 1 $image > $shrunk_img
cat $stripped_img >> $shrunk_img
rm $stripped_img
mv $shrunk_img $image
chmod a+x $image

The above shell is inefficient (space utilization is up to 2x the image size), but safe (the original image isn't deleted until the very end).

But, it would probably be better implemented in the same way as singularity expand.

@dtrudg
Copy link
Contributor

dtrudg commented Jan 3, 2020

This issue is not really present in Singularity 3.x as we now build to SIF images, which are based on a squashfs which takes the size of the content.

@dtrudg dtrudg closed this as completed Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants