A comprehensive CLI tool for Docker optimization and analysis. Trouter CLI helps you build better, more secure, and faster Docker containers.
- Dockerfile Analysis: Multi-stage builds, security, size, and performance analysis
- Optimization Generator: Creates optimized Dockerfile and .dockerignore
- Security Scanning: Vulnerability detection, secret scanning, permission analysis
- Performance Testing: Build time, startup time, memory, CPU, network, and disk I/O testing
- Size Analysis: Layer breakdown and optimization recommendations
npm install -g trouter-clitrouter-cli docker analyze
trouter-cli docker analyze --jsontrouter-cli docker optimize
trouter-cli docker optimize --force # Overwrite existing filestrouter-cli docker scan
trouter-cli docker scan --image my-app:latest
trouter-cli docker scan --jsontrouter-cli docker performance
trouter-cli docker performance --image my-app:latest
trouter-cli docker performance --jsontrouter-cli docker size
trouter-cli docker size --image my-app:latest
trouter-cli docker size --json- Multi-stage build detection
- Package manager detection (npm/yarn/pnpm)
- Security analysis (root user, HTTPS, sensitive data)
- Size estimation and optimization suggestions
- Performance analysis (health checks, resource limits)
- Multi-stage builds for reduced image size
- Non-root user configuration
- Optimized layer caching
- Health check inclusion
- Alpine-based images for smaller size
- Vulnerability detection (Docker Scout/Trivy integration)
- Secret scanning (passwords, tokens, API keys)
- Permission analysis (root user, filesystem, sudo)
- Layer analysis for security issues
- Build time measurement
- Startup time analysis
- Memory usage profiling
- CPU usage monitoring
- Network latency testing
- Disk I/O benchmarking
- Total image size reporting
- Layer breakdown and analysis
- Largest layers identification
- Size optimization tips
$ trouter-cli docker analyze
π Dockerfile Analysis
π Basic Information:
β’ Lines: 30
β’ Base Image: node:18-alpine
β’ Node Version: 18
β’ Package Manager: npm
β’ Stages: 2
β‘ Optimization Analysis:
β’ Multi-stage Build: β
β’ Package Cache: β
β’ .dockerignore: β
β’ Alpine Base: β
β’ Production Flag: β
$ trouter-cli docker scan
π Docker Image Scan Results: my-app:latest
π Vulnerability Scan:
β’ Critical: 0
β’ High: 2
β’ Medium: 5
β’ Low: 12
β’ Info: 8
β’ Total: 27
π Secret Scan:
β
No secrets detected
π€ Permission Analysis:
β’ Running as Root: β
β’ Writable Filesystem: β
β’ Sudo Installed: β
$ trouter-cli docker performance
π Performance Test Results: my-app:latest
π¨ Build Performance:
β’ Average: 15.2s
β’ Min: 12.1s
β’ Max: 18.9s
π Startup Performance:
β’ Average: 2.3s
β’ Min: 1.8s
β’ Max: 3.1s
πΎ Memory Usage:
β’ Current: 128MiB
β’ Total: 2GiB
β’ Percentage: 6%
β’ Efficiency: Excellent-p, --path <path>: Path to project directory (default: current directory)--json: Output results as JSON
-p, --path <path>: Path to project directory (default: current directory)--force: Overwrite existing files
-i, --image <image>: Docker image to scan (builds current project if not specified)--json: Output results as JSON
-i, --image <image>: Docker image to test (builds current project if not specified)--json: Output results as JSON
-i, --image <image>: Docker image to analyze (builds current project if not specified)--json: Output results as JSON
Trouter CLI analyzes your Dockerfile and provides recommendations for:
- Multi-stage builds to reduce final image size
- Layer caching optimization for faster builds
- Security best practices (non-root users, HTTPS base images)
- Size optimization (Alpine images, .dockerignore usage)
- Performance improvements (health checks, resource limits)
The tool scans Docker images for:
- Known vulnerabilities using npm audit and security databases
- Secrets and credentials using pattern matching
- Permission issues (root user, writable filesystems)
- Docker best practices violations
Trouter CLI measures real-world performance metrics:
- Build time across multiple iterations
- Container startup time with health check validation
- Memory and CPU usage under typical load
- Network latency to external services
- Disk I/O performance for read/write operations
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT