slimtoolkit / slim

Slim(toolkit): Don't change anything in your container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)
Apache License 2.0
19.21k stars 716 forks source link

keep libc dependencies after sliming. #481

Closed alifiroozi80 closed 1 year ago

alifiroozi80 commented 1 year ago

Hello guys,

I have Dockerfile, which uses tini for process handling.

Everything is okay if I build the image as usual (docker build -t test:1.0.0 .).

But if I use slim to slim the image and run the newly slimmed Image, it returns:

/tini: error while loading shared librarieshttps://github.com/krallin/tini: libc.so.6: cannot open shared object file: No such file or directory

Its documentation says:

Tini has very few dependencies (it only depends on libc)

So, slim delete this dependency.

How can I keep the libc dependencies after sliming?

kcq commented 1 year ago

Is test:1.0.0 in your experiment a base image that includes the tini binary or is it an application image that happens to include tini too? What is in your Dockerfile? What is it doing?

There's a way to keep extra files and directories using one of the --include-* filags. For example, --include-path is used to keep a file a directory in your image even if it's not used during minification. You can use. this flag to keep libc though you'll need to have extra --include-path flags to include the symlinks for libc too.