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

Open
akkornel opened this Issue Apr 21, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@akkornel
Contributor

akkornel commented Apr 21, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment