Open frakman1 opened 4 years ago
@frakman1 Thank you for opening the ticket! Can you tell me more about your image? What do you mean by It's used for building
? What kind of builds do you do with it? What do you build? What kind of build tools do you have there? What's the ENTRYPOINT and CMD instructions for your image?
When you disable HTTP probing docker-slim
will pause and wait for your input. It does that to allow you to interact with the container out of band, so docker-slim
can observe what's going on with the temporary container it created. You can explicitly configure docker-slim
to use a different continue
mode (using the --continue-after
command line parameter). Other options include timeouts and signals.
This image is on Dockerhub and available for you to pull and inspect at your leisure. See here for the Dockerfile details too.
By building
I mean I use this image to cross compile code for an embedded system. Think Open-WRT. Its job is to provide artifacts that are used in subsequent stages of the CI/CD process. I hope that makes sense. The problem is that it is huge at about 1.5GB and I need to slim it down while still maintaining the same functionality as before. The CMD instruction is just bash
in order to perform all the build/make instructions.
Note that docker run
doesn't get run manually on this image and is part of the Devops framework built into Gitlab whereby I just give it the docker image's name and it pulls it and runs it using the script within a .gitlab-ci.yml
file. I noticed that some of your optimizations require a different docker run
syntax for the slimmed image to work. I hope that isn't the case with my image since I don't have control over that part.
@kcq Does the information I provided make sense? Is it possible to use docker-slim
with such an application or should I give up on this?
@frakman1 Those references to your Dockerfile are super useful! Thank you for providing them! Short answer, yes, it is possible; however, it'll require extra work where we'll need to use the --include-*
parameters in the docker-slim build
command. We can also do a trick with a dummy/test app that would be similar (conceptually) to the embedded apps you build (mounting the sample application code, so it's not included in the final image). There's one extra enhancement that's on the todo list that will make things a bit easier (an ability to keep/include the artifacts based on the package name instead of the file or directory paths or binary names). I hope to add this soonish though I still need to figure out the exact timeline for it. In the meantime, we can try using the existing capabilities. If you can share a simple hello world for your embedded environment it'll be super helpful (for testing/verification and for the minification process too).
@kcq Thank you for the update. I'm excited that this is not completely a lost cause.
I'm not sure what you mean by providing a simple hello world. The docker container downloads toolchains and code from other repos and compiles them into binaries. Those operations take place after launching the container so I don't see how relevant it is in slimming it down.
What I mean is that there is no running app at the end of the day. All what is needed is a container that can run bash scripts in a full Ubuntu environment.
@frakman1 Yes, even though it's going to be a base/builder image it'll be helpful to simulate what will happen with when you use it to build an actual app. For example, the setup might look like this:
docker-slim \
build --http-probe=false \
--include-path "/some/path/in/your/image" \
--include-path "/another/path/in/your/image" \
--mount $PWD/dummyapp:/opt/app \
--entrypoint "make -f /opt/app/Makefile" \
nandkrishnamoorthy/ubuntu:16.04
Running on Linux Ubuntu 14.04.5 LTS
I have a customized ubuntu image that is about 1.5GB that I want to slim down. It's used for building and therefore has no exposed http ports. It has a custom user which is why I use
--include-path /etc/passwd
. When I usedocker-slim
, the resultant image is only 3MB and won't run any commands when I launch it.In the middle of the output, it wants me to press enter to continue:
Am I supposed to have the container running when I run the
docker-slim
command?