docker-slim
Optimize and reduce Docker image size
TLDR
View documentation for the original command
SYNOPSIS
docker-slim [global-options] <command> [options] [args]
Common: docker-slim build [--target <image[:tag]>] [--http-probe] [options]
PARAMETERS
--debug
Enable debug logging
--verbose
Verbose output
--log-level
Set log level (debug,info,warn,error)
--target
Target image to slim (required for build)
--http-probe
Use HTTP probe to detect app readiness (default: auto)
--http-probe-port
HTTP probe port (default: 8080)
--http-probe-path
HTTP probe path (default: /)
--exec
Custom exec command instead of HTTP probe
--cmd
Override CMD in profiled container
--entrypoint
Override ENTRYPOINT
--env
Add environment variables (repeatable)
--include-path
Always include paths (repeatable)
--exclude-path
Exclude paths (repeatable)
--preserve-paths
Preserve specific paths
--dry-run
Dry run without building
--continue-after
Continue after probe success (seconds)
DESCRIPTION
DockerSlim (docker-slim) is an open-source CLI tool that automatically generates slimmer production-ready Docker images. It uses dynamic instrumentation to profile a running container: launches a modified version of the image, monitors filesystem accesses, binary executions, network interactions, and runtime behavior.
The process captures only what's actually used by the application (e.g., specific libraries, files), then creates a new minimal Dockerfile and builds a optimized image. Typical reductions: 30-90% smaller sizes, improving security (smaller attack surface) and deployment speed.
Key features: HTTP health probes for web apps, custom exec commands for others, static xray analysis, Dockerfile linting. Works with most images; best for static-ish apps. Requires Docker daemon. Main workflow: docker-slim build myapp. Supports advanced configs like env vars, path includes/excludes.
CAVEATS
Requires Docker daemon; may miss dynamically loaded content; not for images needing full runtime env; experimental for complex apps; increases build time initially.
SUBCOMMANDS
build: Main slimming; xray: Static image scan; lint: Dockerfile checker; profile: Container profiling.
INSTALLATION
curl -L https://downloads.docksal.io/docker-slim/channels/latest/docker-slim-linux.tar.gz | tar -xzC /usr/local/bin
Or: brew install docker-slim/tap/docker-slim
HISTORY
Developed by dslim-dev starting 2016; v1.36+ (2022+) adds BuildKit support, better ARM; actively maintained on GitHub with 10k+ stars; evolved from static to dynamic analysis focus.


