this post was submitted on 14 Jul 2023
121 points (93.5% liked)

Selfhosted

40394 readers
337 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS
 

As the title says. I build containers for my platforms/clients/myself-selfhosted@home and you would not believe how much smaller you can get your images. Here's an example when slimming one of my images:

cmd=build info=results status='MINIFIED' by='18.97X' size.original='1.0 GB' size.optimized='55 MB' 

That's a Python app that I didn't have to do multi-staged build with docker because of the Slim command. And it's a working version of that app that I'm using today.

Same for one of my flutter apps that I thought it was as small as it could be:

cmd=build info=results status='MINIFIED' by='1.98X' size.original='66 MB' size.optimized='33 MB'

TLDR: slim your container images!! https://github.com/slimtoolkit/slim

you are viewing a single comment's thread
view the rest of the comments
[–] Ramenator@feddit.de 55 points 1 year ago (1 children)

AFAIK it works by analyzing your docker image, checking whats actually used and then throwing out anything else.
For example if you use the Ubuntu base image you have a full minimal OS install. If you're now running a python server for example it's highly unlikely that you will need the perl interpreter that's in the default install so it can be thrown out.
It can get problematic if you want to run something that loads libraries or runs programs dynamically at runtime, since the tool can't easily detect them then and you need to manually intervene. Tried it once on a custom machine learning container and it kept throwing out parts that I actually needed, so I gave up in the end.
It's usefulness is also somewhat limited, since docker containers also share their base images. So if you have three containers running that are all based on Ubuntu 22.04 you will still only have to download it once

[–] FancyGUI@lemmy.fancywhale.ca 15 points 1 year ago

Great write up! That's everything exactly right. It's mostly useful to try and reduce the time it takes to pull images to run them. And also reduce the footprint of storing those in your registries.