Skip to content

Instantly share code, notes, and snippets.

@NikoWoot
Created December 19, 2014 08:37
Show Gist options
  • Save NikoWoot/95cb133dca06143ce629 to your computer and use it in GitHub Desktop.
Save NikoWoot/95cb133dca06143ce629 to your computer and use it in GitHub Desktop.
Reduce size of Docker image
=================================================
After software installation
=================================================
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
=================================================
Docker on build process, include all files on directory build (include .git with old build)
Solution for reduce size of docker image (but for reuse is not good solution)
=================================================
File : .dockerignore
.bundle
.git
log
tmp
vendor
=================================================
Compress docker image
=================================================
ID=$(docker run -d image-name /bin/bash)
(docker export $ID | gzip -c > image.tgz)
gzip -dc image.tgz | docker import - flat-image-name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment