Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build always return error="open slim.report.json: no such file or directory #715

Open
wang2024666 opened this issue Sep 18, 2024 · 4 comments

Comments

@wang2024666
Copy link

Expected Behavior

docker-slim build return 0

version: latest release

Actual Behavior

docker-slim build \

--http-probe=false
--continue-after=1
--include-bin=/bin/bash
--include-shell --include-oslibs-net --include-ssh-client
dmodeler:20240914

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/command_report.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/[email protected]/command.go:279 +0x9dd\ngithub.com/urfave/cli/v2.(*Command).Run(0xc0007134a0, 0xc000698140, {0xc000050120, 0x9, 0x9})\n\tgithub.com/urfave/cli/[email protected]/command.go:272 +0xc2e\ngithub.com/urfave/cli/v2.(*App).RunContext(0xc000150600, {0x23470c8?, 0x341e0a0}, {0xc000050120, 0x9, 0x9})\n\tgithub.com/urfave/cli/[email protected]/app.go:337 +0x5db\ngithub.com/urfave/cli/v2.(*App).Run(...)\n\tgithub.com/urfave/cli/[email protected]/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?

@kcq
Copy link
Member

kcq commented Sep 18, 2024

@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.

@wang2024666
Copy link
Author

@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

@kcq
Copy link
Member

kcq commented Oct 4, 2024

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

@wang2024666
Copy link
Author

wang2024666 commented Oct 12, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants