docker-flatten
is a tool that allows you to flatten Docker images by removing unnecessary layers, turning your container's filesystem into a single pristine layer. This helps reduce image size and removes bloat that accumulates over time.
- Export a running container's filesystem and create a new image from it
- Strip away Docker image layers to create a clean, minimal base
- Simple and efficient for creating optimized Docker images without needing a Dockerfile
-
Clone this repository:
git clone https://github.com/<your-username>/docker-flatten.git
-
Navigate to the repository:
cd docker-flatten
-
Make the script executable:
chmod +x docker-flatten
-
Optionally, move it to a directory in your PATH for easy access:
sudo mv docker-flatten /usr/local/bin/
To flatten an image and create a new minimal image, run the following command:
docker-flatten <source-image> <new-image-name>