Docker — a race for smallest image

  1. Always cleanup your package manager. YUM isn’t as friendly as APT. There’s autoremove but then you should manually remove the cache.
  2. Always remove your downloads. When building from source, always delete leftover build folders, object files and downloaded archives.
  3. Keep your layer count low. Keep singing “Bare necessities” in your head. Don’t use multiple RUN steps to do the same thing, linking several commands in the same RUN is better (and only one thing to cleanup)
  4. If you have multiple RUNs, remember it’s not enough to clean up in the last one. Each layer is independent and must be cleaned independently
  5. Link your commands with && rather than ;. Theres no need to attempt unzip if the download failed.

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store