Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image squashing #22

Closed
wants to merge 23 commits into from
Closed

Add image squashing #22

wants to merge 23 commits into from

Conversation

rafecolton
Copy link
Contributor

Do not merge until:

This adds the experimental squashing feature, which will soon be integrated into docker-builder (also experimental). This allows images to be "squashed" after building and before tagging.

So why do this? Squashing images allows you to drastically optimize the size of your final image while still utilizing the Dockerfile build cache. An example workflow might go as follows:

  • daily
    • build your base image
    • do not squash after building (retain history)
    • tag with date (i.e. :yyyy-mm-dd)
  • as needed
    • use your base image (FROM registry/project:{{ date "2006-01-02" }}) (coming soon)
    • run your build
      • this will add a few more layers but not many
      • commands like bundle install will be fast because they have already run and cached a result in the filesystem of your base (daily) layer
      • include destructive commands in your Dockerfile
        • e.g. RUN rm -rf /some/directory/that/is/not/completely/necessary
    • squash the image to optimize for size of the final image
      • the squash will remove those files from the image, optimizing for space

/cc @alexschlessinger

/cc @burke @sirupsen the addition of this feature may make this close to addressing Shopify's use case

NOTE: This feature still needs a little work - currently, it uses quite a bit of memory while running.

This version (WIP) requires two image readers as input - it uses the
first to determine all metadata it needs for squashing the image.  It
then uses the second to do the actual squashing.
this allows the use of an io.Pipe(), further reducing the overall memory
use
@rafecolton rafecolton changed the title Add image squashing [DNM] Add image squashing Jan 2, 2015
"io"
"strings"

log "github.com/Sirupsen/logrus"
//"github.com/docker/docker/pkg/pools"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commented import should be removed.

@rafecolton rafecolton changed the title [DNM] Add image squashing Add image squashing Jan 15, 2015
@rafecolton
Copy link
Contributor Author

Closing due to inactivity

@rafecolton rafecolton closed this Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants