Skip to content

Instantly share code, notes, and snippets.

@HungUnicorn
Created April 22, 2020 08:06
Show Gist options
  • Save HungUnicorn/af22605c605517226fe70cd262cd991e to your computer and use it in GitHub Desktop.
Save HungUnicorn/af22605c605517226fe70cd262cd991e to your computer and use it in GitHub Desktop.
docker best practices
## Incremental build time
#### Order your steps from least to most frequently changing steps to optimize caching
#### When copying files into your image, make sure you are very specific about what you want to copy. Any changes to the files being copied will break the cache
#### You always want to update the index and install packages in the same RUN: they form together one cacheable unit. Otherwise you risk installing outdated packages.
## Reduce image size
#### Apt has the –no-install-recommends flag which ensures that dependencies that were not actually needed are not installed
#### Remove the cache in the same RUN instruction that installed packages
## Maintainbility
#### Do not use the latest tag and use specific tag
#### Look for minimal flavors
## Reproducibility
#### Multi-build
https://www.docker.com/blog/intro-guide-to-dockerfile-best-practices/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment