My time was consuming me to troubleshoot big Docker images, waiting for builds to complete and worrying about wasted storage. It felt like no matter how carefully I structured my Dockerfiles, the images always ended up heavier than they needed. I found SlimToolkit (formerly DockerSlim) that all changed.
The application analyses a Docker image,identifies the file and dependency required at runtime (and deletes everything else) and removes files. How do I shrink my Docker images without breaking anything and follow this guide to see how SlimToolkit works?
SlimToolkit Simplifies Docker Image Optimization
This is an open-source tool called **SlimToolkit that reduces Docker image size without requiring changes to application code or Dockersfiles. That means it eliminates the need for manual optimization steps (such as cleaning packages or rewriting build stages) of its . SlimToolkit does not use image optimization automatically, instead and keeps the process simple. *****
When you run SlimToolkit on a Docker image, it performs ‘dynamic analysis’ by watching how the container runs. In execution it tracks exactly what files, libraries and dependencies the application touches while being executed. This data allows it to develop a new, optimized image with only the components required. This keeps the original image intact, so that it is safe and easy to reverse a process.
SlimToolkit works with existing images and supports Node using Nodes. Without learning advanced Docker or Linux, js, Python, Java and Go. With its integration with most workflows, it helps to enhance container security by removing tools and shell that attacker could exploit. Big win for CI/CD pipelines is that smaller images download faster, start quicker and consume less resources.
Setting Up SlimToolkit
The easiest way is to use SlimToolkit via Docker, which requires no local installation. Until Docker is installed and running, you can install slimtoolkit right away.
First, download the official SlimToolkit image using the following docker command:
docker
pull dslim
/
slim

In order to run SlimToolkit, the Docker socket (/var /run/docker) must be mounted on the docker device (i.e. Sock) sock () That enables the container to communicate with your local Docker engine for analysis and optimization of photos. So you only use trusted official images,’ paraphrast.
Reducing Docker Image Size with SlimToolkit
To demonstrate the optimization process, we will slim a standard Nginx image. First, pull the official, latest Nginx image:
docker
pull nginx:latest

A direct run of build command is available to you for standard applications such as Nginx. The container is actually used by a file that is checked by SlimToolkit and removes the unnecessary files, which are not required.
docker
run
--rm
-v
/
var
/
run
/
docker.sock:
/
var
/
run
/
docker.sock dslim
/
slim build
--target
nginx:latest
--tag
nginx-slim:latest

Depending on the language (such as Python or Ruby) dependencies that are not immediately activated during a standard probe, some languages (e.g. In those cases, write an “ignore” in which a is used. When I ask SlimToolkit which folders to keep, such as “/usr/local /lib-python3”, using txt” file. 11” . But this stops slimtoolkit from taking away crucial running time responsibilities.
You can run the command with a volume mount to include your preservation rules:
-v
"
$(pwd)
"
:
/
target
--preserve-path-file
/
target
/
ignore.txt
Compare Size Difference: Original Vs. Slimmed Image
When the process is complete, SlimToolkit stores local image optimization. For example, with this command you can compare the size difference between original and slimmed version of .
docker
images
You’ll likely see a dramatic reduction.

Finally, test your new optimized image to ensure it works as expected:
docker
run
-it
-p
8080
:
80
nginx-slim:latest

Please navigate throughhttp//localhost808 and open your browser for . This is a way to see the default Nginx welcome page, but running from’very small container footprints’.

Other Useful SlimToolkit Commands
There are a few key commands from SlimToolkit to help you analyze and optimize Docker images. Here’s the best of all.
| Command | Description |
| — | — |
| slim build | Optimizes a Docker image by keeping only the necessary files and dependencies, reducing image size. |
| slim xray | Analyzes a Docker image and shows what’s inside, including files, layers, and dependencies. |
| slim lint | Checks Dockerfiles for errors to prevent build issues. |
| slim debug | Allows debugging a running container created from a slimmed Docker image. |
| slim profile | Collects information about a Docker image and outputs a JSON report for size and performance analysis. |
| slim merge | Merges two Docker images into a single image. |
You can also check all available SlimToolkit commands and their usage using the following command.
docker
run
--rm
-v
/
var
/
run
/
docker.sock:
/
var
/
run
/
docker.sock dslim
/
slim slim
help

Limitations to Keep in Mind
While SlimToolkit helps reduce Docker image sizes, you should consider a few drawbacks:
- Slimming large images can take longer, so plan accordingly.
If a particular code path is not executed during build process, and the tool uses dynamic analysis (such as * Because), SlimToolkit may think that ‘a dependency has been unneeded to be used by itself.’ The software also deletes it from its own database after using an app called “SlimTool Kit”. Have your slimmed pictures always be tested by a , and never take the most seriously.
It often removes tools such as bash or curl to save space for a , and * it also sometimes deletes tool (e.g. They’re a good example of how to troubleshoot inside – and you have to tell SlimToolkit explicitly that they will keep them.
Wrapping Up
Adding SlimToolkit to your workflow speeds up deployments, ensures consistent performance and reduces container bloat? Keeping your original builds the same, it helps you create cleaner and more professional Docker images while keeping your own versions of them clean. Furthermore, following the best Docker cleaning practices ensures that containers are more efficiently and well-organized over time.
Thanks for reading Use This Tool to Reduce Your Docker Images Size and Improve Performance