Open wang2024666 opened 1 month ago
@wang2024666 looks like the build was successful (based on the output... e.g., cmd=build info=results status='MINIFIED' by='9.39X' size.original='4.1 GB' size.optimized='432 MB'
).
Looks like your current working directory is not writable, so saving the slim.report.json execution report file fails. A few options... You can run DockerSlim from a different directory or you can explicitly save the report in a different location, which can be done using the global --report
flag (this flag needs to be provided before the command name: docker-slim --report /your/preferred/location/slim.report.json build
). You can also disable saving reports by setting the --report
flag value to off
.
@kcq thanks,the --report flag works. even we run with shell include as: docker-slim --report /root/slim.report.json build \ --http-probe=false \ --continue-after=1 \ --include-shell=true \ --include-oslibs-net=true \ --include-ssh-client=true \ ndsmodeler:20240914 the contiainer seems still missing the shell environment. [root@localhost ~]# docker exec -it caf51e6fff9d /bin/bash OCI runtime exec failed: exec failed: unable to start container process: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown [root@localhost ~]# docker exec -it caf51e6fff9d /bin/sh OCI runtime exec failed: exec failed: unable to start container process: exec: "/bin/sh": stat /bin/sh: no such file or directory: unknown [root@localhost ~]# docker exec -it caf51e6fff9d sh OCI runtime exec failed: exec failed: unable to start container process: exec: "sh": executable file not found in $PATH: unknown how can we keep the shell environment and basic os commands? the base image is CentOS Stream 8
Not quite sure what kind of base image you have there... Looks like some kind of flavor of CentOS Stream 9.
Just in case try also including bash in the /usr/bin directory and its sh symlink (if you have it):
--include-bin /usr/bin/bash
--include-path /usr/bin/sh
And also try using the include exec flag:
--include-exe bash
hi Kyle, Yes, the base image is Centos Stream 9. with command: docker-slim --report /root/slim.report.json build \ --http-probe=false \ --continue-after=1 \ --include-shell=true \ --include-bin /usr/bin/bash --include-path /usr/bin \ --include-exe bash \ --include-oslibs-net=true \ --include-ssh-client=true \ ndsmodeler:20241012 we get the new image and then run the image, we hope to list the files in it. but it returns:
docker exec -it 93503f259e71 /bin/bash
bash-5.1# ls
/usr/bin/coreutils: error while loading shared libraries: libselinux.so.1: cannot open shared object file: No such file or directory
bash-5.1# cd app
bash: cd: app: No such file or directory
bash-5.1# cd /app
bash-5.1# ls
/usr/bin/coreutils: error while loading shared libraries: libselinux.so.1: cannot open shared object file: No such file or directory
bash-5.1# ll
bash: ll: command not found
bash-5.1# dir
/usr/bin/coreutils: error while loading shared libraries: libselinux.so.1: cannot open shared object file: No such file or directory
how can we keep the basic OS libs and commands included?
thanks.
From: Kyle Quest Date: 2024-10-05 07:42 To: slimtoolkit/slim CC: wang2024666; Mention Subject: Re: [slimtoolkit/slim] build always return error="open slim.report.json: no such file or directory (Issue #715) Not quite sure what kind of base image you have there... Looks like some kind of flavor of CentOS Stream 9. Just in case try also including bash in the /usr/bin directory and its sh symlink (if you have it): --include-bin /usr/bin/bash --include-path /usr/bin/sh And also try using the include exec flag: --include-exe bash — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Expected Behavior
docker-slim build return 0
version: latest release
Actual Behavior
docker-slim build \
the output is: cmd=build state=started cmd=build info=params target.type='image' target.image='10.122.92.94/3dopen-private/nds3dmodeler:20240914' continue.mode='timeout' rt.as.user='true' keep.perms='true' tags='' image-build-engine='internal' cmd=build state=image.inspection.start cmd=build info=image id='sha256:b1f71d5cc16bf0397c252a509b23ef1e66ce0bd5edb95b7ee68cf742fc811a0e' size.bytes='4056190549' size.human='4.1 GB' cmd=build info=image.stack index='0' name='10.122.92.94/dotnet/centos-stream-dotnet:stream9.8' id='sha256:36fe389a0b5d7c2c1f8a6944744b4a82b1786ce3d1df0ba70cad537a76fd3ae7' cmd=build info=image.stack index='1' name='10.122.92.94/3dopen-private/nds3dmodeler:20240914' id='sha256:b1f71d5cc16bf0397c252a509b23ef1e66ce0bd5edb95b7ee68cf742fc811a0e' cmd=build state=image.inspection.done cmd=build state=container.inspection.start cmd=build info=container id='8e767aa9eb69e2d439791a36b751095a2062cad7044b046e41e63dc62aff1790' status='created' name='slimk_1889964_20240918083627' cmd=build info=container status='running' name='slimk_1889964_20240918083627' id='8e767aa9eb69e2d439791a36b751095a2062cad7044b046e41e63dc62aff1790' cmd=build info=container message='obtained IP address' ip='172.17.0.2' cmd=build info=cmd.startmonitor status='sent' cmd=build info=event.startmonitor.done status='received' cmd=build info=container target.port.info='' message='YOU CAN USE THESE PORTS TO INTERACT WITH THE CONTAINER' name='slimk_1889964_20240918083627' id='8e767aa9eb69e2d439791a36b751095a2062cad7044b046e41e63dc62aff1790' target.port.list='' cmd=build info=continue.after message='no input required, execution will resume after the timeout' mode='timeout' cmd=build prompt='waiting for the target container (1 seconds)' cmd=build info=event message='done waiting for the target container' cmd=build state=container.inspection.finishing cmd=build state=container.inspection.artifact.processing cmd=build state=container.inspection.done cmd=build state=building message="building optimized image" engine=internal cmd=build state=completed cmd=build info=results status='MINIFIED' by='9.39X' size.original='4.1 GB' size.optimized='432 MB' cmd=build info=results image-build-engine='internal' image.name='10.122.92.94/3dopen-private/nds3dmodeler.slim' image.size='432 MB' image.id='sha256:a9f87f955b9e6ac37dd9a9b88317ab5bf9fa1664d825882cc1df20bc9ac903d6' image.digest='sha256:b2dbd15c431a27a6c73d0c6ef406d2de59ba8b357f197569dc9889a2c76db1d8' has.data='true' cmd=build info=results artifacts.location='/tmp/slim-state/.slim-state/images/b1f71d5cc16bf0397c252a509b23ef1e66ce0bd5edb95b7ee68cf742fc811a0e/artifacts' cmd=build info=results artifacts.report='creport.json' cmd=build info=results artifacts.dockerfile.reversed='Dockerfile.reversed' cmd=build info=results artifacts.seccomp='10.122.92.94-3dopen-private-nds3dmodeler-seccomp.json' cmd=build info=results artifacts.apparmor='10.122.92.94-3dopen-private-nds3dmodeler-apparmor-profile' cmd=build state=done cmd=build info=commands message='use the xray command to learn more about the optimize image' time="2024-09-18T16:36:37+08:00" level=fatal msg="slim: failure" error="open slim.report.json: no such file or directory" stack="goroutine 1 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x5e\ngithub.com/slimtoolkit/slim/pkg/util/errutil.FailOn({0x2328f40, 0xc000978570})\n\tgithub.com/slimtoolkit/slim/pkg/util/errutil/errutil.go:32 +0x4b\ngithub.com/slimtoolkit/slim/pkg/report.(Command).saveInfo(0xc000097c00, {0x1d73020, 0xc000097c00})\n\tgithub.com/slimtoolkit/slim/pkg/report/command_report.go:559 +0x41b\ngithub.com/slimtoolkit/slim/pkg/report.(BuildCommand).Save(...)\n\tgithub.com/slimtoolkit/slim/pkg/report/commandreport.go:573\ngithub.com/slimtoolkit/slim/pkg/app/master/command/build.finishCommand(0xc00039cd20, {0xc00071c000, 0x2d}, {0x0, 0x0}, 0x0, {0x0, 0x0}, {0xc0000f0007, 0x40}, ...)\n\tgithub.com/slimtoolkit/slim/pkg/app/master/command/build/handler.go:1703 +0x1d08\ngithub.com/slimtoolkit/slim/pkg/app/master/command/build.OnCommand(, , {, }, , {, }, {, }, {0x0, ...}, ...)\n\tgithub.com/slimtoolkit/slim/pkg/app/master/command/build/handler.go:1245 +0x5385\ngithub.com/slimtoolkit/slim/pkg/app/master/command/build.glob..func1(0xc000698b80)\n\tgithub.com/slimtoolkit/slim/pkg/app/master/command/build/cli.go:760 +0x5d51\ngithub.com/urfave/cli/v2.(Command).Run(0x33a7220, 0xc000698b80, {0xc0001a8780, 0x8, 0x8})\n\tgithub.com/urfave/cli/v2@v2.27.1/command.go:279 +0x9dd\ngithub.com/urfave/cli/v2.(Command).Run(0xc0007134a0, 0xc000698140, {0xc000050120, 0x9, 0x9})\n\tgithub.com/urfave/cli/v2@v2.27.1/command.go:272 +0xc2e\ngithub.com/urfave/cli/v2.(App).RunContext(0xc000150600, {0x23470c8?, 0x341e0a0}, {0xc000050120, 0x9, 0x9})\n\tgithub.com/urfave/cli/v2@v2.27.1/app.go:337 +0x5db\ngithub.com/urfave/cli/v2.(App).Run(...)\n\tgithub.com/urfave/cli/v2@v2.27.1/app.go:311\ngithub.com/slimtoolkit/slim/pkg/app/master.Run()\n\tgithub.com/slimtoolkit/slim/pkg/app/master/app.go:15 +0x45\nmain.main()\n\tgithub.com/slimtoolkit/slim/cmd/slim/main.go:15 +0x187\n" version="linux/amd64|Transformer|1.40.11|1b271555882eacdfb4e6598d6d0552e9b9b1449b|2024-02-02_01:36:22PM" [root@localhost logs]# echo $? 1 how to resolve this issue?