brando56894 Posted August 15, 2017 Share Posted August 15, 2017 (edited) I couldn't find any information on how to resize the image without destroying the one currently used (which would require reinstalling all the containers). So I used my Google-fu to see if there was anything on the interwebs but couldn't find anything relating to images, just partitions, but I figured I'd give it a try since I had backed up the original. You can do the first two steps while the image is mounted and it doesn't matter is you specify the mount point (/var/lib/docker) or the image itself (/mnt/user/system/docker/docker.img) Step 1: Check the image's filesystem for errors btrfsck -p --repair /mnt/user/system/docker/docker.img Step 2: Resize the filesystem btrfs filesystem resize [new size] /mnt/user/system/docker/docker.img UNMOUNT THE IMAGE Step 3: Resize the image itself dd if=/mnt/user/system/docker/docker.img of=/mnt/user/system/docker/docker.img.new bs=2M count=6000 status=progress The above command will resize the image to 12 GB (2 MB block size, 6,000 blocks is about 12,000 MB/12 GB) Step 4: Make sure the image mounts mount /mnt/user/system/docker/docker.img.new /var/lib/docker; ls /var/lib/docker You should see the Docker filesystem in /var/lib/docker, now just unmount the image and either delete or rename the old docker.img and rename docker.img.new to docker.img and you're done! Edited August 15, 2017 by brando56894 Quote Link to comment
Squid Posted August 15, 2017 Share Posted August 15, 2017 8 minutes ago, brando56894 said: I couldn't find any information on how to resize the image without destroying the one currently used (which would require reinstalling all the containers). Ugh... Very, very simple to enlarge the image https://forums.lime-technology.com/topic/57181-real-docker-faq/#comment-565307 How do I increase the size of my docker.img file? Go to settings - Docker Settings. Set Enable Docker to be "No" Apply. Switch to Advanced View (Top Right) Change the size of the image. Set Enable Docker to be "yes" Apply Done. Quote Link to comment
Squid Posted August 15, 2017 Share Posted August 15, 2017 Oops Missed that you were shrinking not enlarging Quote Link to comment
brando56894 Posted August 15, 2017 Author Share Posted August 15, 2017 (edited) You completely missed the point of the post @Squid did you even read it? I changed the title because I'm assuming you just glanced at the title and went "ugh, silly noobs" and just copied that from your FAQ. I'm doing the exact opposite of that, this was due to me increasing the size to 50 GB using the method posted above when I was trying to figure out why my image was running out of space, and once I did I found out that my containers took up about 5 GB worth of space in the image, yet it was taking up 50 GB on my cache drive. Edit: you beat me to it haha Edited August 15, 2017 by brando56894 Quote Link to comment
Squid Posted August 15, 2017 Share Posted August 15, 2017 Just now, brando56894 said: You completely missed the point of the post @Squid did you even read it? I changed the title because I'm assuming you just glanced at the title and went "ugh, silly noobs" and just copied that from your FAQ. I'm doing the exact opposite of that, this was due to me increasing the size to 50 GB using the method posted above when I was trying to figure out why my image was running out of space, and once I did I found out that my containers took up about 5 GB worth of space in the image, yet it was taking up 50 GB on my cache drive. Edit: you beat me to it haha Yeah, I think the original title didn't specify shrink, so yes I glanced, looked at the headache, and posted. But, even there its still probably easier to just delete the image, and redownload the apps. 30 seconds later with no template changes required you're back in business. But it is kinda cool to know how to do a shrink via the command line. Quote Link to comment
brando56894 Posted August 15, 2017 Author Share Posted August 15, 2017 Just now, Squid said: Yeah, I think the original title didn't specify shrink, so yes I glanced, looked at the headache, and posted. Haha I know the feeling, I work in IT and have been a member of the FreeNAS forums (and other Linux forums) for years and usually do the same And yes I did change the title because it wasn't descriptive enough. 2 minutes ago, Squid said: But, even there its still probably easier to just delete the image, and redownload the apps. 30 seconds later with no template changes required you're back in business. I have 12 containers setup, so it would probably take like 5 minutes to setup all the paths and containers again, not a big deal but still something I would like to avoid if at all possible. Quote Link to comment
Squid Posted August 15, 2017 Share Posted August 15, 2017 I have 12 containers setup, so it would probably take like 5 minutes to setup all the paths and containers again, not a big deal but still something I would like to avoid if at all possible.You never need to reset up the paths. Via the docker tab you can add a template (select the my user template) everything will be filled out for you.Under the apps tab go to previous apps and reinstall. Same thing all your paths are already filled out.Under 6.4 with the apps tab you can check off multiple apps at a time then install them all with one button press with no interaction needed at all from the previous apps sectionSent from my LG-D852 using Tapatalk 1 Quote Link to comment
brando56894 Posted August 15, 2017 Author Share Posted August 15, 2017 Ah good to know! In FreeNAS we had to do it all over again once you deleted the container. Quote Link to comment
JonathanM Posted August 15, 2017 Share Posted August 15, 2017 2 hours ago, brando56894 said: Ah good to know! In FreeNAS we had to do it all over again once you deleted the container. unRAID != FreeNAS Quote Link to comment
brando56894 Posted August 15, 2017 Author Share Posted August 15, 2017 Old habits die hard! Quote Link to comment
ken-ji Posted August 16, 2017 Share Posted August 16, 2017 Just going to add my 2 bits: When you shrink, you should ensure that the size you give in the filesystem shrink command is a bit smaller than the resulting size from your DD command. otherwise, you run the risk of truncating the filesystem and destroying it. I've had to redo vm image copies over a WAN before when we did some shrinking and we ended up with disks/partitions that were truncated by a few sectors at the end. ugh. 1 Quote Link to comment
steve1977 Posted June 2, 2018 Share Posted June 2, 2018 On 8/15/2017 at 6:27 PM, Squid said: But, even there its still probably easier to just delete the image, and redownload the apps. 30 seconds later with no template changes required you're back in business. But it is kinda cool to know how to do a shrink via the command line. Can you explain a bit more what I'll need to do. What about all my docker settings? Do I need to re-do all of them. It took me ages to configure musicbrainz docker et al. Will this be impacted? Quote Link to comment
Squid Posted June 2, 2018 Share Posted June 2, 2018 12 hours ago, steve1977 said: Can you explain a bit more what I'll need to do. What about all my docker settings? Do I need to re-do all of them. It took me ages to configure musicbrainz docker et al. Will this be impacted? Nope. All of your appdata remains intact. Quote Link to comment
steve1977 Posted June 3, 2018 Share Posted June 3, 2018 Great, thanks, I successfully shrank the image. Indeed worked very easily by deleting and new creating. Quote Link to comment
jpotrz Posted November 19, 2018 Share Posted November 19, 2018 I had just posted a question about resizing the docker.img on Reddit a few minutes ago, then stumbled on this thread It seems the "right" way to do this is to actually delete the dockers, then the image, then reset the image size, then reinstall the dockers? I'm confused as to how all my settings remain etc though? Quote Link to comment
Cessquill Posted December 5, 2018 Share Posted December 5, 2018 On 11/19/2018 at 3:10 PM, jpotrz said: It seems the "right" way to do this is to actually delete the dockers, then the image, then reset the image size, then reinstall the dockers? I'm confused as to how all my settings remain etc though? All your settings are stored in your appdata share, which is separate to the docker image (and likely on your cache drive). The configuration of each docker (eg, the ports and shares it can access) are remembered by unraid as templates. Theoretically, the only thing in the docker image file are the dockers themselves, and once installed should only change when new versions are downloaded - everything else that changes is in appdata* * not always the case - log files can be in docker containers, as can data if a docker's been misconfigured. Came here looking for the best way to shrink your image file (after I raised it whilst tracking down a problem). Didn't know you could batch install with Community Applications. Result! Quote Link to comment
mizifih Posted March 24, 2020 Share Posted March 24, 2020 (edited) Label: none uuid: 47d2ad00-2f07-4eeb-a68f-448568ed8f73 Total devices 1 FS bytes used 3.97GiB devid 1 size 20.00GiB used 5.52GiB path /dev/loop2 I guess I could shrink a lot. Can I do this through Settings/Docker already or do I still have only those two options, Terminal or deleting and reinstalling apps? Edited March 24, 2020 by mizifih typo Quote Link to comment
Squid Posted March 24, 2020 Share Posted March 24, 2020 2 hours ago, mizifih said: deleting and reinstalling apps? ^^ This. But, I wouldn't worry about it with a 20G docker.img file Quote Link to comment
mizifih Posted March 24, 2020 Share Posted March 24, 2020 53 minutes ago, Squid said: ^^ This. But, I wouldn't worry about it with a 20G docker.img file Yes, it's not like 20GB is too much, but my cache is always being filled so fast. It's probably Deluge, since I'm re-downloading a lot of stuff. I'll see how it's going to behave once all the torrenting slows down, but I think I'll have to squeeze a few GB wherever I can if this trend continues. I have a 250GB m.2 drive as cache. Quote Link to comment
dcoens Posted June 20, 2020 Share Posted June 20, 2020 I know this is a older thread, but my docker.img is also 50GB and I wanted to shrink it, but I get an error. I tried it both with the docker mounted and unmounted. my docker takes uses only 6GB and wanted to shrink it to 10GB. is their a new way of doing this or any suggestions? Thanks in advanced. _________ Label: none uuid: f49bb50d-4601-4f39-8969-7fe3ac318b0a Total devices 1 FS bytes used 4.45GiB devid 1 size 50.00GiB used 6.07GiB path /dev/loop2 _________ btrfs filesystem resize 10GB /mnt/cache/docker.img ERROR: resize works on mounted filesystems and accepts only directories as argument. Passing file containing a btrfs image would resize the underlying filesystem instead of the image. Quote Link to comment
JorgeB Posted June 20, 2020 Share Posted June 20, 2020 Just now, dcoens said: or any suggestions? You should recreate it instead: https://forums.unraid.net/topic/57181-docker-faq/?do=findComment&comment=564309 Quote Link to comment
dcoens Posted June 20, 2020 Share Posted June 20, 2020 ok. will do - thanks for the link Quote Link to comment
mycarrysun Posted January 25 Share Posted January 25 Welp...I lost all my docker networks when I tried deleting the docker img file and then recreating...hope no one else had to go through and manually setup all their docker containers again like me. I'd rather just do the original shrink method. Wish it was done in the Web GUI when you change the docker vdisk size option. Quote Link to comment
JorgeB Posted January 26 Share Posted January 26 14 hours ago, mycarrysun said: I tried deleting the docker img file and then recreating...hope no one else had to go through and manually setup all their docker containers again like me. That should not happen, did you follow the instructions? https://docs.unraid.net/unraid-os/manual/docker-management/#re-create-the-docker-image-file Quote Link to comment
JonathanM Posted January 30 Share Posted January 30 On 1/25/2024 at 6:17 PM, mycarrysun said: Welp...I lost all my docker networks when I tried deleting the docker img file and then recreating. Did you successfully follow the directions here and still lose the networks? Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.