{"id":13449006,"url":"https://github.com/jwilder/docker-squash","last_synced_at":"2025-12-15T02:33:34.624Z","repository":{"id":19672991,"uuid":"22926658","full_name":"jwilder/docker-squash","owner":"jwilder","description":"Squash docker images to make them smaller","archived":true,"fork":false,"pushed_at":"2021-05-21T22:47:46.000Z","size":61,"stargazers_count":1983,"open_issues_count":0,"forks_count":158,"subscribers_count":42,"default_branch":"master","last_synced_at":"2024-09-26T22:04:31.652Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jwilder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-13T18:33:13.000Z","updated_at":"2024-09-26T11:03:57.000Z","dependencies_parsed_at":"2022-08-24T14:07:51.547Z","dependency_job_id":null,"html_url":"https://github.com/jwilder/docker-squash","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwilder%2Fdocker-squash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwilder%2Fdocker-squash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwilder%2Fdocker-squash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwilder%2Fdocker-squash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwilder","download_url":"https://codeload.github.com/jwilder/docker-squash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234410239,"owners_count":18828163,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T06:00:28.295Z","updated_at":"2025-09-27T07:31:41.113Z","avatar_url":"https://github.com/jwilder.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# This is project is no longer under development\n\ndocker-squash\n=============\n\nSquash docker images to make them smaller.\n\ndocker-squash is a utility to squash multiple docker layers into one in order to create an image\nwith fewer and smaller layers.  It retains Dockerfile commands such as PORT,\nENV, etc.. so that squashed images work the same as they were originally built.  In addition, deleted\nfiles in later layers are actually purged from the image when squashed.\n\nIt's designed to support a workflow where you would squash the image just before pushing it\nto a registry.  Before squashing the image, you would remove any build time dependencies, extra\nfiles (apt caches, logs, private keys, etc..) that you would not want to deploy.  The defaults also\npreserve your base image so that its contents are not repeatedly transferred when pushing and pulling\nimages.\n\nTypical workflow is:\n\n* Build image from Dockerfile (or other)\n* Run clean up commands in container (apt-get purge, rm /path, etc..)\n* Commit container\n* Squash the image\n* Push squashed image to registry\n\nSee [Squashing Docker Images](http://jasonwilder.com/blog/2014/08/19/squashing-docker-images/)\n\n## Sample Output\n\n```\n$ docker save 49b5a7a88d5 | sudo docker-squash -t squash -verbose | docker load\nLoading export from STDIN using /tmp/docker-squash683466637 for tempdir\nLoaded image w/ 15 layers\nExtracting layers...\n  -  /tmp/docker-squash683466637/49b5a7a88d5353fe77204ad5591a3ef100fc2807a9d6dce979fd1b17a73a68d6/layer.tar\n  -  /tmp/docker-squash683466637/651626d6e364ccc22ac990ba95cd0aab9256c56055087cc9a5a1790cea5250b9/layer.tar\n  -  /tmp/docker-squash683466637/c50f2b65cab3b74f9bdb6f616b36f132b9a182ed883d03f11173e32fa39ab599/layer.tar\n  -  /tmp/docker-squash683466637/d92c3c92fa73ba974eb409217bb86d8317b0727f42b73ef5a05153b729aaf96b/layer.tar\n  -  /tmp/docker-squash683466637/511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158/layer.tar\n  -  /tmp/docker-squash683466637/1c9383292a8ff4c4196ff4ffa36e5ff24cb217606a8d1f471f4ad27c4690e290/layer.tar\n  -  /tmp/docker-squash683466637/589338fba5eb5cc32a25a036975a5e0938f12eff0dc70b661363c13ef1a192a5/layer.tar\n  -  /tmp/docker-squash683466637/63e174c2ca3d53e2b7639a440940e16e15c1970e6ad16f740ffdcc60e59e0324/layer.tar\n  -  /tmp/docker-squash683466637/9942dd43ff211ba917d03637006a83934e847c003bef900e4808be8021dca7bd/layer.tar\n  -  /tmp/docker-squash683466637/0ea0d582fd9027540c1f50c7f0149b237ed483d2b95ac8d107f9db5a912b4240/layer.tar\n  -  /tmp/docker-squash683466637/8dfc0bb00563dab615dfcc28ab3e338089f5b1d71d82d731c18cbe9f7667435f/layer.tar\n  -  /tmp/docker-squash683466637/c4ff7513909dedf4ddf3a450aea68cd817c42e698ebccf54755973576525c416/layer.tar\n  -  /tmp/docker-squash683466637/cc58e55aa5a53b572f3b9009eb07e50989553b95a1545a27dcec830939892dba/layer.tar\n  -  /tmp/docker-squash683466637/e4eea4411c0065f8b0c7cf6be31dd58daa5ac04d8c64d54537cbfce2eb8e3413/layer.tar\n  -  /tmp/docker-squash683466637/fc294d2b22cb53cb2440ff6fece18813ee7363f5198f5e20346abfcf7cce54fe/layer.tar\nInserted new layer 27935276f797 after 1c9383292a8f\n  -  511136ea3c5a\n  -  1c9383292a8f /bin/sh -c #(nop) ADD file:c1472c26527df28498744f9e9e8a8304c\n  -\u003e 27935276f797 /bin/sh -c #(squash) from 1c9383292a8f\n  -  9942dd43ff21 /bin/sh -c echo '#!/bin/sh' \u003e /usr/sbin/policy-rc.d  \u0026\u0026 echo\n  -  d92c3c92fa73 /bin/sh -c rm -rf /var/lib/apt/lists/*\n  -  0ea0d582fd90 /bin/sh -c sed -i 's/^#\\s*\\(deb.*universe\\)$/\\1/g' /etc/apt/\n  -  cc58e55aa5a5 /bin/sh -c apt-get update \u0026\u0026 apt-get dist-upgrade -y \u0026\u0026 rm -\n  -  c4ff7513909d /bin/sh -c #(nop) CMD [/bin/bash]\n  -  fc294d2b22cb /bin/sh -c apt-get update \u0026\u0026 apt-get install -y golang-go\n  -  8dfc0bb00563 /bin/sh -c #(nop) ADD dir:78239d85b32dd28e4cb1d81ace7ffd32b8\n  -  651626d6e364 /bin/sh -c #(nop) WORKDIR /app\n  -  589338fba5eb /bin/sh -c go build -o http\n  -  c50f2b65cab3 /bin/sh -c #(nop) ENV PORT=8000\n  -  e4eea4411c00 /bin/sh -c #(nop) EXPOSE map[8000/tcp:{}]\n  -  63e174c2ca3d /bin/sh -c #(nop) CMD [/app/http]\n  -  49b5a7a88d53 /bin/bash\nSquashing from 27935276f797 into 27935276f797\n  -  Deleting whiteouts\n  -  Rewriting child history\n  -  Removing 9942dd43ff21. Squashed. (/bin/sh -c echo '#!/bin/sh' \u003e /usr/sbin/policy-...)\n  -  Removing d92c3c92fa73. Squashed. (/bin/sh -c rm -rf /var/lib/apt/lists/*)\n  -  Removing 0ea0d582fd90. Squashed. (/bin/sh -c sed -i 's/^#\\s*\\(deb.*universe\\)$/\\1...)\n  -  Removing cc58e55aa5a5. Squashed. (/bin/sh -c apt-get update \u0026\u0026 apt-get dist-upgra...)\n  -  Replacing c4ff7513909d w/ new layer 72391e640b52 (/bin/sh -c #(nop) CMD [/bin/bash])\n  -  Removing fc294d2b22cb. Squashed. (/bin/sh -c apt-get update \u0026\u0026 apt-get install -y...)\n  -  Removing 8dfc0bb00563. Squashed. (/bin/sh -c #(nop) ADD dir:78239d85b32dd28e4cb1d...)\n  -  Replacing 651626d6e364 w/ new layer bd7b4b11874a (/bin/sh -c #(nop) WORKDIR /app)\n  -  Removing 589338fba5eb. Squashed. (/bin/sh -c go build -o http)\n  -  Replacing c50f2b65cab3 w/ new layer e4af8871b961 (/bin/sh -c #(nop) ENV PORT=8000)\n  -  Replacing e4eea4411c00 w/ new layer 6803497b6a61 (/bin/sh -c #(nop) EXPOSE map[8000/tcp:{}])\n  -  Replacing 63e174c2ca3d w/ new layer 40b8c7c33bba (/bin/sh -c #(nop) CMD [/app/http])\n  -  Removing 49b5a7a88d53. Squashed. (/bin/bash)\nTarring up squashed layer 27935276f797\nRemoving extracted layers\nTagging 40b8c7c33bba as jwilder/whoami:squash\nTarring new image to STDOUT\nDone. New image created.\n  -  40b8c7c33bba Less than a second /bin/sh -c #(nop) CMD [/app/http] 3.072 kB\n  -  6803497b6a61 Less than a second /bin/sh -c #(nop) EXPOSE map[8000/tcp:{}] 3.072 kB\n  -  e4af8871b961 Less than a second /bin/sh -c #(nop) ENV PORT=8000 3.072 kB\n  -  bd7b4b11874a Less than a second /bin/sh -c #(nop) WORKDIR /app 3.072 kB\n  -  72391e640b52 Less than a second /bin/sh -c #(nop) CMD [/bin/bash] 3.072 kB\n  -  27935276f797 1 seconds /bin/sh -c #(squash) from 1c9383292a8f 39.49 MB\n  -  1c9383292a8f 3 days /bin/sh -c #(nop) ADD file:c1472c26527df28498744f9e9e8a83... 201.6 MB\n  -  511136ea3c5a 14 months  1.536 kB\nRemoving tempdir /tmp/docker-squash683466637\n```\n\n## Installation\n\nDownload the latest version:\n\n* [Linux linux/amd64](https://github.com/jwilder/docker-squash/releases/download/v0.2.0/docker-squash-linux-amd64-v0.2.0.tar.gz)\n* [OSX darwin/amd64](https://github.com/jwilder/docker-squash/releases/download/v0.2.0/docker-squash-darwin-amd64-v0.2.0.tar.gz)\n\n```\n$ wget https://github.com/jwilder/docker-squash/releases/download/v0.2.0/docker-squash-linux-amd64-v0.2.0.tar.gz\n$ sudo tar -C /usr/local/bin -xzvf docker-squash-linux-amd64-v0.2.0.tar.gz\n```\nNOTE: docker-squash must run as root (to maintain file permission created within images).\n\nDependencies:\n\n* [tar 1.27](http://www.gnu.org/software/tar/)\n\n## Usage\n\ndocker-squash works by squashing a saved image and loading the squashed image back into docker.\n\n```\n$ docker save \u003cimage id\u003e \u003e image.tar\n$ sudo docker-squash -i image.tar -o squashed.tar\n$ cat squashed.tar | docker load\n$ docker images \u003cnew image id\u003e\n```\n\nYou can also tag the squashed image:\n\n```\n$ docker save \u003cimage id\u003e \u003e image.tar\n$ sudo docker-squash -i image.tar -o squashed.tar -t newtag\n$ cat squashed.tar | docker load\n$ docker images \u003cnew image id\u003e\n```\n\nYou can reduce disk IO by piping the input and output to and from docker:\n\n```\n$ docker save \u003cimage id\u003e | sudo docker-squash -t newtag | docker load\n```\n\nIf you have a sufficient amount of RAM, you can also use a `tmpfs` to remove temporary\ndisk storage:\n\n```\n$ docker save \u003cimage_id\u003e | sudo TMPDIR=/var/run/shm docker-squash -t newtag | docker load\n```\n\nBy default, a squashed layer is inserted after the first `FROM` layer.  You can specify a different\nlayer with the `-from` argument.\n```\n$ docker save \u003cimage_id\u003e | sudo docker-squash -from \u003cother layer\u003e -t newtag | docker load\n```\nIf you are creating a base image or only want one final squashed layer, you can use the\n`-from root` to squash the base layer and your changes into one layer.\n\n```\n$ docker save \u003cimage_id\u003e | sudo docker-squash -from root -t newtag | docker load\n```\n\n### Development\n\nThis project uses [glock](https://github.com/robfig/glock) for managing 3rd party dependencies.\nYou'll need to install glock into your workspace before hacking on docker-squash.\n\n```\n$ git clone \u003cyour fork\u003e\n$ glock sync github.com/jwilder/docker-squash\n$ make\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwilder%2Fdocker-squash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwilder%2Fdocker-squash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwilder%2Fdocker-squash/lists"}