Optimizing Docker image size
There's a nice blog on optimizing Docker image size. I learned about tools that I haven't known about before, especially dive. This lets you troubleshoot your Docker images and even tells you when you have files duplicated in different layers in your image. It's a great way to discover waste in your images.
The HN thread also has a bunch of useful tips for managing layers:
You can use
--squash to remove all intermediate layers
RUN <<EOF apt-get update apt-get upgrade -y apt-get install -y ... EOF
There's a tool called
stargz (seekable tar.gz format) which greatly improves
startup time in container images by lazy loading files stargz
Look at how it improves startup time for python-3.7 image:
This is built on top of the Google CRFS (Container Registry Filesystem) project which is a FUSE filesystem that lets you mount a container image served directly from a container registry without pulling it locally first. The linked repo has a fantastic README that explains how it all works.