Hi guys, is there any guidance on how to figure out base image and add that to xray?
@yashbhutwala great to see that you looked at the code :-) there’s actually quite a bit of information related to the base image information when you run the xray command. For example, here’s what I got running
docker-slim xray dslimexamples/server-node-hapi-alpine (server-node-haps-alpine is one of the sample app, so you can try it yourself):
Dockerfile for the image starts with:
The console output from the xray command has this line:
docker-slim[xray]: info=image.stack index=0 name='node:6.11.0-alpine' id='sha256:b7535c8c7bee13ca6c082141f5416f2f5d9b8bf68a61cb9e6ce82d42773aa40d' instructions=8 message='see report file for details’
Note how the
name field value is
node:6.11.0-alpine, which matches the FROM instruction value.
The slim.report.json file (that gets generated when the command is done) includes
6.11.0-alpine in one of the
And the auto-generated Dockerfile.fat file has line:
# end of image: node:6.11.0-alpine (id: tags: node:6.11.0-alpine)
level=fatal msg="docker-slim: failure" error="source is not a regular file"
--include-pathworks with directories too, so no need to include each file individually
./docker-slim build --http-probe fogf.18.04.tar:latest)
—include-*parameters you can use too:
—include-binis a more intelligent version of
include-pathwhen it comes to keeping additional binary files in your optimized image. It will include the file you specify and it will also include any other files that binary references, so if you
—include-bina shared object (aka dynamic library)
docker-slimwill include that shared object and it will also include the shared libraries that shared object imports.
—include-shellincludes enough executables to give you a basic read-only shell experience
-vdocker run param) when you run your optimized container. Would it be possible to do? There’s a couple of extra capabilities I can add to docker-slim to streamline this use case. One is an ability to copy files within the container image when docker-slim is running it. This would make it possible to mount your clean config as a new file and then it would replace the modified config file. Another option is a capability to add extra files to the optimized image during the build step, so you’d be able to replace the modified config file with a fresh copy.
--preserve-path. Set its value to your entrypoint’s file path something like this:
docker-slim build --preserve-path /path/to/your/entrypoint.sh your-container-image-name
-preserve-pathflag and lots of other enhancements. Give it a try (linux:
docker-slimdefines how you want to decide when the analysis is done. The parameter defaults to
probe, which means that
docker-slimwill wait until all (http) probes are done executing and then it moves on to the next phase. In addition to configuring custom http probe commands with
--http-probe-cmd-fileyou can also invoke external apps during the probing phase. This can be done using the
--http-probe-exec-fileparameters, which allows you to use those external apps to decide when the analysis is done.
—continue-afteroptions you can use to decide when the analysis phase is done.
docker-slimto wait for external console input. That way you can manually signal the end of the analysis phase.
--continue-afteroption lets you use unix signals to let
docker-slimknow when the analysis phase should be done.
—continue-afteroption lets you indicate that you want the analysis phase to be done once the shell commands passed through the
—exec-fileparams are done executing in the temporary container.
--continue-after probe&exec). With these stacked options the analysis phase will be done once the exec commands are done executing and the probing phase is done.
docker runparameters to the
docker-slim buildcommand? Some/all of the ones mentioned here: https://docs.docker.com/engine/reference/commandline/run/ . For my use case I'm looking to increase the shm size via
--cro-shm-size), but there’s already a flag you can leverage to get the same results. It’s called
--cro-host-config-fileand you can specify a custom shared mem size in the
ShmSizethere. You’ll need to build the latest code yourself to get the