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.64k stars 737 forks source link

Using Host network #82

Open couillonnade opened 5 years ago

couillonnade commented 5 years ago

Hello,

I am trying to reduce an image based on Debian but I have some issues with the Network. The image I am working on is this one: https://hub.docker.com/r/torpi/roon-core

For some reasons, Roon-Server must run on Host network. Clients and endpoints will not connect otherwise so I cannot run scenarios for the reduction and end with a non-working image.

My naive approch was to set the network like we do with docker run or docker-compose:

./docker-slim build --network="host" imageid

Unfortunately this does not work and the error is not really helpful to me. I was not able to find more information on github or leveraging Google.

Is that a limitation of the tool or am I doing something wrong? Any help would be appreciated!

docker-slim[build]: state=started docker-slim[build]: info=params target=fc706cdecd24 continue.mode=enter docker-slim[build]: state=inspecting.image docker-slim[build]: info=image id=sha256:fc706cdecd247e3e1d9af9fb40cfe270b2e6509706268895abbeb94dea89c77b size.bytes=562111628 size.human=562 MB docker-slim[build]: info=image.layers index=0 name='torpi/roon-core' tags='latest' docker-slim[build]: state=inspecting.container docker-slim[build]: info=container status=created id=eaa479b8ec017f7d68479ecb4bb2e6b8c25134d1a1e110caafc85100d3949d3b time="2019-06-19T18:32:55Z" level=fatal msg="docker-slim: failure" error="docker-slim: error => missing comms ports" stack="goroutine 1 [running]: runtime/debug.Stack(0x17a1, 0xc000126480, 0x3) /usr/local/Cellar/go/1.11.1/libexec/src/runtime/debug/stack.go:24 +0xa7 github.com/docker-slim/docker-slim/pkg/utils/errutils.FailWhen(0xc00017e001, 0x90ce57, 0x29) /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/pkg/utils/errutils/errutils.go:30 +0x53 github.com/docker-slim/docker-slim/internal/app/master/inspectors/container.(*Inspector).RunContainer(0xc000088a80, 0xc000127048, 0x1) /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/internal/app/master/inspectors/container/container_inspector.go:324 +0x13df github.com/docker-slim/docker-slim/internal/app/master/commands.OnBuild(0x868101, 0x0, 0x0, 0x0, 0xc000206180, 0x17, 0xc00007a150, 0x7ffc2810a787, 0xc, 0x0, ...) /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/internal/app/master/commands/build.go:157 +0xf7f github.com/docker-slim/docker-slim/internal/app/master.init.0.func6(0xc000174140, 0x0, 0xc000174140) /Users/q/docker-slim/docker-slim/_gopath/src/github.com/docker-slim/docker-slim/internal/app/master/cli.go:606 +0x1209 github.com/docker-slim/docker-slim/vendor/github.com/codegangsta/cli.HandleAction(0x857400, 0x91a070, 0xc000174140, 0xc00005a000, 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(0x8fabe6, 0x5, 0x0, 0x0, 0xc0000995f0, 0x1, 0x1, 0x912fad, 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(0xc0000aeb60, 0xc00008a000, 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:906 +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.0|4d304c9adf0d2315ec8d4ca197070f040500cc68|2019-04-25_01:57:04AM (go1.11.1)"

kcq commented 5 years ago

Thank you for raising an issue for this! It's an opportunity to improve docker-slim and I really appreciate it. Let me take a look at the image and investigate and i'll post an update shortly.

couillonnade commented 5 years ago

Thanks for your feedback, let me know if you need any information. It's a basic image that runs a Roon Core Server. You can connect to the server with the control application (https://roonlabs.com/downloads.html). They are discovering the server only in the same subnet so unless you set mDNS and route the traffic correctly, it won't work if the remote and server are in different subnets.

openedhardware commented 3 years ago

@kcq Any update here?

I have a same issue.. My container should run in host mode, but it fails to build:

ubuntu@ubuntu-desktop:$ docker-slim build --network="host" --http-probe=false --continue-after 1 --mount /viso:/viso --include-path /usr/local/lib/python3.6/dist-packages/certifi --show-clogs local
docker-slim: message='join the Gitter channel to ask questions or to share your feedback' info='https://gitter.im/docker-slim/community'
docker-slim: message='join the Discord server to ask questions or to share your feedback' info='https://discord.gg/9tDyxYS'
docker-slim[build]: state=started
docker-slim[build]: info=params target=local continue.mode=timeout rt.as.user=true keep.perms=true
docker-slim[build]: state=image.inspection.start
docker-slim[build]: info=image id=sha256:f5cd536b720823dd89da6714ed27a2a664c3e155f8cf623d8537f73c0ef7f32b size.bytes=2013445341 size.human=2.0 GB
docker-slim[build]: info=image.stack index=0 name='tensorflow/tensorflow:2.3.1' id='sha256:a6528f3f080b6af82fccae4eb82f2b7f040ae7c78ec18523b3068574136668bd'
docker-slim[build]: info=image.stack index=1 name='local:latest' id='sha256:f5cd536b720823dd89da6714ed27a2a664c3e155f8cf623d8537f73c0ef7f32b'
docker-slim[build]: state=image.inspection.done
docker-slim[build]: state=container.inspection.start
docker-slim[build]: info=container status=created name=dockerslimk_20487_20210125105748 id=a1edaf190fc2823d99dc2aecf11c7d3bd88207b6832c0bc85c47f6779c461318
time="2021-01-25T20:57:48+10:00" level=fatal msg="docker-slim: failure" error="docker-slim: error => missing comms ports" stack="goroutine 1 [running]:\nruntime/debug.Stack(0x0, 0xc0004339a0, 0x16)\n\truntime/debug/stack.go:24 +0x9d\ngithub.com/docker-slim/docker-slim/pkg/util/errutil.FailWhen(0xc00020e601, 0xdbaabc, 0x29)\n\tgithub.com/docker-slim/docker-slim/pkg/util/errutil/errutil.go:34 +0x53\ngithub.com/docker-slim/docker-slim/internal/app/master/inspectors/container.(*Inspector).RunContainer(0xc0004fe000, 0x4, 0xc0001f9960)\n\tgithub.com/docker-slim/docker-slim/internal/app/master/inspectors/container/container_inspector.go:527 +0x1bf5\ngithub.com/docker-slim/docker-slim/internal/app/master/commands/build.OnCommand(0xc00038e190, 0x7ffd1de44e35, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)\n\tgithub.com/docker-slim/docker-slim/internal/app/master/commands/build/handler.go:284 +0x172c\ngithub.com/docker-slim/docker-slim/internal/app/master/commands/build.glob..func1(0xc0000e3e40, 0x0, 0xc0001d3a60)\n\tgithub.com/docker-slim/docker-slim/internal/app/master/commands/build/cli.go:361 +0x1eb1\ngithub.com/urfave/cli.HandleAction(0xc55700, 0xdd9870, 0xc0000e3e40, 0xc0000e3e40, 0x0)\n\tgithub.com/urfave/cli@v1.22.4/app.go:526 +0x11a\ngithub.com/urfave/cli.Command.Run(0xd97655, 0x5, 0x0, 0x0, 0x155e550, 0x1, 0x1, 0xdcdc8a, 0x6c, 0x0, ...)\n\tgithub.com/urfave/cli@v1.22.4/command.go:174 +0x57a\ngithub.com/urfave/cli.(*App).Run(0xc000358380, 0xc0000b2000, 0xc, 0xc, 0x0, 0x0)\n\tgithub.com/urfave/cli@v1.22.4/app.go:279 +0x7c7\ngithub.com/docker-slim/docker-slim/internal/app/master.Run()\n\tgithub.com/docker-slim/docker-slim/internal/app/master/app.go:15 +0x54\nmain.main()\n\tgithub.com/docker-slim/docker-slim/cmd/docker-slim/main.go:8 +0x20\n" version="linux|Transformer|1.33.0|da7983050b8bf326c6f8e73ddce43a5b8d54da4b|2020-12-12_08:18:23PM"
jotaoncode commented 2 years ago

@kcq

I also hit the same issue not entirely sure how to proceed with it:

➜  categories git:(main) ✗ docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock dslim/docker-slim build testing --expose 3000 --env MYSQL_SERVICE_HOST=$(minikube ip) --env MYSQL_SERVICE_PORT='30020' --env MYSQL_USER_NAME='root' --env MYSQL_ROOT_PASSWORD='12345' --network host
docker-slim: message='join the Gitter channel to ask questions or to share your feedback' info='https://gitter.im/docker-slim/community'
docker-slim: message='join the Discord server to ask questions or to share your feedback' info='https://discord.gg/9tDyxYS'
docker-slim: message='Github discussions' info='https://github.com/docker-slim/docker-slim/discussions'
cmd=build info=param.http.probe message='using default probe' 
cmd=build state=started
cmd=build info=params tags='' target.type='image' target='testing' continue.mode='probe' rt.as.user='true' keep.perms='true' 
cmd=build state=image.inspection.start
cmd=build info=image id='sha256:802b92e8b268a25184778704b773450d592cdd4f18c211d390922c6855b124c2' size.bytes='251027928' size.human='251 MB' 
cmd=build info=image.stack id='sha256:bb1fcdaff9369c498f6161d85f8a082c10012c0a8d6b9c76f5140abce7841c78' index='0' name='node:17-alpine' 
cmd=build info=image.stack name='testing:latest' id='sha256:802b92e8b268a25184778704b773450d592cdd4f18c211d390922c6855b124c2' index='1' 
cmd=build state=image.inspection.done
cmd=build state=container.inspection.start
cmd=build info=container name='dockerslimk_1_20220201150455' id='2fde1b1afeffef7bbb5fa8a1c402d6d0efeeeabf9a3960eed1d6e12ada3520c0' status='created' 
time="2022-02-01T15:05:56Z" level=error msg="channel.NewCommandClient: NewClient error = wait timeout"
time="2022-02-01T15:05:56Z" level=error msg="ipc.NewClient init error = wait timeout"
time="2022-02-01T15:05:56Z" level=fatal msg="docker-slim: failure" error="wait timeout" stack="goroutine 1 [running]:\nruntime/debug.Stack(0xc00009c0c0, 0x21, 0xc000257140)\n\truntime/debug/stack.go:24 +0x9f\ngithub.com/docker-slim/docker-slim/pkg/util/errutil.FailOn(0xf2d7c0, 0xc000376c70)\n\tgithub.com/docker-slim/docker-slim/pkg/util/errutil/errutil.go:28 +0x54\ngithub.com/docker-slim/docker-slim/pkg/app.(*ExecutionContext).FailOn(0xc00045c280, 0xf2d7c0, 0xc000376c70)\n\tgithub.com/docker-slim/docker-slim/pkg/app/execontext.go:43 +0x3a\ngithub.com/docker-slim/docker-slim/pkg/app/master/commands/build.OnCommand(0xc00045c280, 0xc00026c230, 0x7ffe38f69ed8, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)\n\tgithub.com/docker-slim/docker-slim/pkg/app/master/commands/build/handler.go:893 +0x2de5\ngithub.com/docker-slim/docker-slim/pkg/app/master/commands/build.glob..func1(0xc0005c8000, 0xc0005c0000, 0xc0005c06f0)\n\tgithub.com/docker-slim/docker-slim/pkg/app/master/commands/build/cli.go:629 +0x31fb\ngithub.com/urfave/cli.HandleAction(0xcaea20, 0xe30af8, 0xc0005c8000, 0xc0005c8000, 0x0)\n\tgithub.com/urfave/cli@v1.22.4/app.go:526 +0x105\ngithub.com/urfave/cli.Command.Run(0xdeab23, 0x5, 0x0, 0x0, 0x146f8e0, 0x1, 0x1, 0xe24dad, 0x6c, 0x0, ...)\n\tgithub.com/urfave/cli@v1.22.4/command.go:174 +0x579\ngithub.com/urfave/cli.(*App).Run(0xc000178e00, 0xc000130000, 0xf, 0xf, 0x0, 0x0)\n\tgithub.com/urfave/cli@v1.22.4/app.go:279 +0x808\ngithub.com/docker-slim/docker-slim/pkg/app/master.Run()\n\tgithub.com/docker-slim/docker-slim/pkg/app/master/app.go:15 +0x54\nmain.main()\n\tgithub.com/docker-slim/docker-slim/cmd/docker-slim/main.go:8 +0x25\n" version="linux|Transformer|1.37.3|97eb3c8c7f8c4e295a26c13882feb3f0539ab50f|2021-12-10_11:34:02AM"

I am using a Linux Manjaro, I tried to define a few environment variables to use my minikube mysql instance with my machine as a host.

This works fine if I do this:

docker run -e MYSQL_SERVICE_HOST=$(minikube ip) -e MYSQL_SERVICE_PORT='30020' -e MYSQL_USER_NAME='root' -e MYSQL_ROOT_PASSWORD='12345' --network host testing

meaning I am able to access my database and the network host with my testing container is fine... also trying a bit further using the --env worked fine, but the problem is mainly when I try to set the flag "network" to host during the build slim image... Any guidance or if I can assist with further logs let me know, and thanks for your help.