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.56k stars 735 forks source link

error while compressing buildstream/buildstream image #92

Open byteshiva opened 5 years ago

byteshiva commented 5 years ago

I'm getting below error while compressing buildstream/buildstream image,. Can someone tell me if I'm missing something here.

$ docker-slim build --http-probe buildstream/buildstream
docker-slim[build]: info=http.probe message='using default probe'
docker-slim[build]: state=started
docker-slim[build]: info=params target=buildstream/buildstream continue.mode=enter
docker-slim[build]: state=image.inspection.start
time="2019-10-11T11:11:05+05:30" level=fatal msg="docker-slim: failure" error="remove /home/user/.asdf/installs/docker-slim/1.25.3/bin/.docker-slim-state/images/9678d0392a820ceed97f8d4e2914234b610ef539949d15d8e7226d8bb7a5ebe1/artifacts/files/etc/ld.so.cache: permission denied" stack="goroutine 1 [running]:
runtime/debug.Stack(0xc00051a1e0, 0x0, 0xc0003cc000)
    /usr/local/Cellar/go/1.11.1/libexec/src/runtime/debug/stack.go:24 +0xa7
github.com/docker-slim/docker-slim/pkg/util/errutil.FailOn(0x98b540, 0xc0005025a0)
    /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/pkg/util/errutil/errutil.go:14 +0x51
github.com/docker-slim/docker-slim/pkg/util/fsutil.PrepareImageStateDirs(0xc000442080, 0x30, 0xc0001ec007, 0x40, 0x0, 0x0, 0x0, 0x0, 0x20, 0x904fc4)
    /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/pkg/util/fsutil/fsutil.go:564 +0x6eb
github.com/docker-slim/docker-slim/internal/app/master/commands.OnBuild(0x86d701, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc00007db30, 0x0, 0x0, 0x7ffe907c1417, ...)
    /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/internal/app/master/commands/build.go:156 +0x8c2
github.com/docker-slim/docker-slim/internal/app/master.init.0.func6(0xc0000e0b40, 0x0, 0xc0000e0b40)
    /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/internal/app/master/cli.go:682 +0x1310
github.com/docker-slim/docker-slim/vendor/github.com/codegangsta/cli.HandleAction(0x85c9c0, 0x920a38, 0xc0000e0b40, 0xc000072700, 0x0)
    /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/vendor/github.com/codegangsta/cli/app.go:485 +0xc8
github.com/docker-slim/docker-slim/vendor/github.com/codegangsta/cli.Command.Run(0x900af0, 0x5, 0x0, 0x0, 0xc000069750, 0x1, 0x1, 0x919408, 0x3e, 0x0, ...)
    /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/vendor/github.com/codegangsta/cli/command.go:207 +0x991
github.com/docker-slim/docker-slim/vendor/github.com/codegangsta/cli.(*App).Run(0xc000096b60, 0xc00001c0c0, 0x4, 0x4, 0x0, 0x0)
    /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/vendor/github.com/codegangsta/cli/app.go:250 +0x6ea
github.com/docker-slim/docker-slim/internal/app/master.runCli()
    /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/internal/app/master/cli.go:1027 +0x55
github.com/docker-slim/docker-slim/internal/app/master.Run()
    /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/internal/app/master/app.go:6 +0x25
main.main()
    /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/cmd/docker-slim/main.go:8 +0x20
" version="linux|Transformer|1.25.3|b5aef546a575de242b2c3ace97e1fc11f028b137|2019-08-04_04:31:18PM" 
kcq commented 4 years ago

This is an interesting use case... Thank you for opening the ticket @byteshiva ! I assume this is the Dockerfile for the image you are trying to minify: https://gitlab.com/BuildStream/buildstream-docker-images/blob/master/buildstream/latest.Dockerfile . I also assume you want the tools explicitly installed in that Dockerfile to stay there, so you can use them later. Can you share an example (or two :-)) of how you use the BuildStream image? Trying to understand how to support this use case...

The failure itself is a bit strange... It complains about a permission problem with the files docker-slim copied from the temporary container it created internally. The latest version of docker-slim shouldn't have the same permission problem because it archives the container artifacts before they are copied from the target container, so the docker-slim master app doesn't need to worry about the permissions set on the files that were copied.

byteshiva commented 4 years ago

This is an interesting use case... Thank you for opening the ticket @byteshiva ! I assume this is the Dockerfile for the image you are trying to minify: https://gitlab.com/BuildStream/buildstream-docker-images/blob/master/buildstream/latest.Dockerfile . I also assume you want the tools explicitly installed in that Dockerfile to stay there, so you can use them later. Can you share an example (or two :-)) of how you use the BuildStream image? Trying to understand how to support this use case...

The failure itself is a bit strange... It complains about a permission problem with the files docker-slim copied from the temporary container it created internally. The latest version of docker-slim shouldn't have the same permission problem because it archives the container artifacts before they are copied from the target container, so the docker-slim master app doesn't need to worry about the permissions set on the files that were copied.

To start with, I'd like to create a disposable dev/sandbox environment along with buildstream to deliver different packages right from flatpak to go executables. Based on the meta data the dev Container profile changes. Why to choose docker-slim, for the obvious reason to lower the size of dockers.

There is another usecase where I would like to create a disposable go dev server to capitalize some of the language server protocol features. In this usecase I would have very low end machine for development all the heavy lifting code analysis and build and others would be done on the remote server. It could be related with cloud IDEs.

Let me test it with latest docker-slim and will update with it's state of error.