{"id":18825417,"url":"https://github.com/grycap/sldocker","last_synced_at":"2026-05-18T03:35:50.153Z","repository":{"id":149748442,"uuid":"222928564","full_name":"grycap/sldocker","owner":"grycap","description":"SLDocker stands for Strip Layers from Docker... ","archived":false,"fork":false,"pushed_at":"2019-11-20T12:24:37.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2026-02-12T07:09:17.998Z","etag":null,"topics":["containers","docker","docker-images","filesystem","hacking"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grycap.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-20T12:05:43.000Z","updated_at":"2020-07-06T22:55:57.000Z","dependencies_parsed_at":"2023-04-25T03:39:07.147Z","dependency_job_id":null,"html_url":"https://github.com/grycap/sldocker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/grycap/sldocker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grycap%2Fsldocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grycap%2Fsldocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grycap%2Fsldocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grycap%2Fsldocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grycap","download_url":"https://codeload.github.com/grycap/sldocker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grycap%2Fsldocker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33163780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"online","status_checked_at":"2026-05-18T02:00:06.436Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["containers","docker","docker-images","filesystem","hacking"],"created_at":"2024-11-08T00:59:24.343Z","updated_at":"2026-05-18T03:35:50.148Z","avatar_url":"https://github.com/grycap.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sldocker\n\nWe can create Docker images, strip layers from them and join to create a new image made from the files created during independent stages from a Dockerfile.\n\n`sldocker` automates the process strip layers from one image, add to other image and create a new different one.\n\nA working example is included:\n\n```\n#!/bin/bash\ndocker build builds -f builds/Dockerfile.vim -t sldocker:vim\ndocker build builds -f builds/Dockerfile.nfs -t sldocker:nfs\ndocker build builds -f builds/Dockerfile.cowsay -t sldocker:cowsay\ndocker build builds -f builds/Dockerfile.all -t sldocker:all\n./sldocker ubuntu:latest sldocker:nfs sldocker:composed -r\n./sldocker sldocker:composed sldocker:cowsay sldocker:composed -r\n./sldocker sldocker:composed sldocker:vim sldocker:composed -r\ndocker images sldocker\n````\n\nUsage:\n\n```\nusage:\n    sldocker [ -n \u003cnum\u003e ] [ -r ] \u003csrc1\u003e \u003csrc2\u003e \u003cdst\u003e\n\n    Gets \u003cnum\u003e layers from docker image src2 and adds them to src1. The \n      resulting docker image is registered as \u003cdst\u003e\n\n\t-n \u003cnum\u003e \t- number of last layers to add from docker image src2 \n                  to docker image src1. Default: 1\n\t-r          - remove \u003cdst\u003e docker image if exists\n```\n\nSLDocker stands for Strip Layers from Docker images.\n\n## The technique behind sldocker\n\nWe can obtain the content of a Docker image by issuing a command like this:\n\n````\n$ docker save ubuntu:latest -o ubuntu.tar\n```\n\nIf we extract the files into a folder\n\n```\n$ mkdir ubuntu\n$ tar xf ubuntu.tar -C ubuntu\n$ cd ubuntu\n````\n\nWe can see all those files. In particular, we’ll pay attention to manifest.json. That file contains the description of the image:\n\n```\n$ cat manifest.json | json_pp\n[\n {\n “Layers” : [\n “c9adcff797cd2265d1371a...e7378527a75/layer.tar”,\n “d69dfec63ea3b06516553e...d9f843d49ba/layer.tar”,\n “06c32c985d45dd7d91c0ee...a093b68c269/layer.tar”,\n “f7d431ec58e467db749850...d5e3d0d8a41/layer.tar”\n ],\n “RepoTags” : [\n “ubuntu:latest”\n ],\n “Config” : “ea4c82dcd15a33e3e9c4c3...c4e98387e39.json”\n }\n]\n```\n\n## How each layer is created\nWhen creating a Docker image, we need to create a Dockerfile in which we state what happens. It is like “installing the things inside the container”. An example follows…\nConsider the next file called Dockerfile.vim\n\n```dockerfile\nFROM ubuntu:latest\nRUN apt update \u0026\u0026 apt -y dist-upgrade\nRUN apt install -y vim — no-install-recommends\n```\n\nNow we can create a docker image by issuing the next command:\n\n```\ndocker build . -f Dockerfile.vim -t sldocker:vim\n```\n\nIf we save that Docker image and check its manifest file, we’ll see the next things:\n\n```\n$ docker save sldocker:vim -o vim.tar\n$ mkdir vim\n$ tar xf vim.tar -C vim/\n$ cat vim/manifest.json | json_pp\n[\n {\n “RepoTags” : [\n “sldocker:vim”\n ],\n “Layers” : [\n  “c9adcff797cd2265d1371a...e7378527a75/layer.tar”,\n  “d69dfec63ea3b06516553e...d9f843d49ba/layer.tar”,\n  “06c32c985d45dd7d91c0ee...a093b68c269/layer.tar”,\n  “36691ebe02d53adf02bc6b...23acf265885/layer.tar”,\n  “f30e5425e2e22ae1cbc56f...8c9bdab8ec8/layer.tar”,\n  “81752c417c9aa667d48049...23c4e9ae167/layer.tar”\n ],\n “Config” :\n  “237dc6ec07959488c5a3ae...a0191aafed1.json”\n }\n]\n```\n\nThere are new layers. And each layer corresponds to the files added during a running step of the “Dockerfile.vim”.\n\n```\n$ tar tf vim/f30e5425e2e22ae1cbc56f...8c9bdab8ec8/layer.tar\nbin/\nbin/bash\nbin/bunzip2\nbin/bzcat\nbin/bzcmp\n(...)\nvar/log/apt/\nvar/log/apt/eipp.log.xz\nvar/log/apt/history.log\nvar/log/apt/term.log\nvar/log/dpkg.log\n````\n\nAnd f30.. correspond to “apt update \u0026\u0026 apt dist-upgrade”, while 817... correspond to “apt -y install vim”.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrycap%2Fsldocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrycap%2Fsldocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrycap%2Fsldocker/lists"}