{"id":16662452,"url":"https://github.com/nicolast/static-container-registry","last_synced_at":"2025-03-21T17:32:03.509Z","repository":{"id":45856000,"uuid":"183610781","full_name":"NicolasT/static-container-registry","owner":"NicolasT","description":"Tools to construct a read-only container 'registry' served by plain Nginx","archived":false,"fork":false,"pushed_at":"2021-12-01T16:50:12.000Z","size":28,"stargazers_count":73,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T03:14:31.690Z","etag":null,"topics":["container-image","container-registry","containers","docker","docker-registry","docker-registry-v2","oci","oci-image","registry"],"latest_commit_sha":null,"homepage":"","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/NicolasT.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":"2019-04-26T10:40:24.000Z","updated_at":"2025-02-24T07:24:22.000Z","dependencies_parsed_at":"2022-09-14T12:02:17.097Z","dependency_job_id":null,"html_url":"https://github.com/NicolasT/static-container-registry","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasT%2Fstatic-container-registry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasT%2Fstatic-container-registry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasT%2Fstatic-container-registry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasT%2Fstatic-container-registry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NicolasT","download_url":"https://codeload.github.com/NicolasT/static-container-registry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244838536,"owners_count":20518823,"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":["container-image","container-registry","containers","docker","docker-registry","docker-registry-v2","oci","oci-image","registry"],"created_at":"2024-10-12T10:37:57.844Z","updated_at":"2025-03-21T17:31:58.475Z","avatar_url":"https://github.com/NicolasT.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"static-container-registry\n=========================\nThis is a set of scripts to create a Docker-compatible read-only 'registry' that\ncan be served by a static Nginx HTTP server, without the need to run a\nfull-fledged registry solution.\n\nGetting Started\n---------------\nFirst, create a directory that'll contain all images that should be part of the\nregistry, e.g.\n\n```\n$ mkdir images/\n```\n\nThen, for every image you want to serve, fetch the image using `skopeo` into a\n`dir` target. For every image `name:tag`, create a directory `name` in the root\ndirectory, and let `skopeo` copy the image into `name/tag`:\n\n```\n$ mkdir images/alpine images/metalk8s-keepalived\n$ skopeo copy --format v2s2 --dest-compress docker://docker.io/alpine:3.9.3 dir:images/alpine/3.9.3\n$ skopeo copy --format v2s2 --dest-compress docker://docker.io/alpine:3.9 dir:images/alpine/3.9\n$ skopeo copy --format v2s2 --dest-compress docker-daemon:alpine:3.8.4 dir:images/alpine/3.8.4\n$ skopeo copy --format v2s2 --dest-compress docker://docker.io/nicolast/metalk8s-keepalived:latest dir:images/metalk8s-keepalived/latest\n```\n\nFor extra credits, we tell `skopeo` to compress all layers.\n\nIn the example above, we pulled Alpine 3.9(.3) twice. As a result, the same\nfiles are now stored multiple files on the system. If many of your images use\nthe same base image(s), this can quickly add up. Luckily, there's an easy way to\nreduce this overhead since these files are always immutable: use hardlinks!\nThere's a tool which does exactly this, aptly called `hardlink`:\n\n```\n$ hardlink -c -vv images\nLinked images/metalk8s-keepalived/latest/version to images/alpine/3.9.3/version, saved 33\nLinked images/metalk8s-keepalived/latest/version to images/alpine/3.8.4/version, saved 33\nLinked images/alpine/3.9.3/cdf98d1859c1beb33ec70507249d34bacf888d59c24df3204057f9a6c758dddb to images/alpine/3.9/cdf98d1859c1beb33ec70507249d34bacf888d59c24df3204057f9a6c758dddb, saved 1512\nLinked images/metalk8s-keepalived/latest/version to images/alpine/3.9/version, saved 33\nLinked images/alpine/3.9.3/bdf0201b3a056acc4d6062cc88cd8a4ad5979983bfb640f15a145e09ed985f92 to images/alpine/3.9/bdf0201b3a056acc4d6062cc88cd8a4ad5979983bfb640f15a145e09ed985f92, saved 2757009\nLinked images/alpine/3.9.3/manifest.json to images/alpine/3.9/manifest.json, saved 528\n\n\nDirectories 7\nObjects 24\nIFREG 17\nComparisons 7\nLinked 6\nsaved 2781184\n```\n\nNow we're ready to create an Nginx configuration file that can be `include`d in\na larger configuration:\n\n```\n$ ./static-container-registry.py ./images \u003e registry.conf\n```\n\nThe following options are available:\n\n- `--name-prefix PREFIX` will prefix `PREFIX` to every container name. As an\n  example, given the layout above, setting this to `myproject` would make\n  `docker pull registry.domain.tld/myproject/alpine:3.9` work, instead of `docker pull\n  registry.domain.tld/alpine:3.9`.\n- `--server-root PATH` tells the script where the image files will be stored on\n  the web-server. This defaults to the provided image path when the script is\n  executed. Hint: this can be any string, including a variable name (e.g.\n  `$registry_root`, though remember to take care of shell quoting!), which can\n  then be defined (`set $registry_root /path/to/images`) in another Nginx\n  configuration file).\n- Finally, the positional argument must be the path to the image files. This can\n  be unspecified, which will then default to the current working directory.\n\nAll that's left to be done is firing up `nginx` with the configuration\n`include`d.\n\nUsing Docker\n------------\nA Docker container image for this project is automatically built\n[on DockerHub](https://hub.docker.com/r/nicolast/static-container-registry).\nTo use this image, first create a directory containing all required image blobs\n(see above), then run\n\n```\n$ docker run \\\n    --name static-oci-registry \\\n    -p 127.0.0.1:80:80 \\\n    --mount type=bind,source=/absolute/path/to/images,destination=/var/lib/images,ro \\\n    --rm \\\n    --read-only \\\n    --mount type=tmpfs,destination=/run \\\n    --mount type=tmpfs,destination=/var/cache/nginx \\\n    docker.io/nicolast/static-container-registry:latest\n```\n\nMake sure to replace the path to the `images`, which should be exposed at\n`/var/lib/images` to the container.\n\nGoals and non-goals\n-------------------\nThis tool is supposed to 'implement' the Docker distribution APIs to the extent\nrequired for `docker pull` (and other container runtimes and tools) to work.\nThis does not necessarily imply all subtle details of the distribution API,\nincluding error reporting, are fully implemented.\n\nThis tool does not, and will never, support uploads (`push`) of new images.\n\nThanks\n------\n- [@mtrmac](https://github.com/mtrmac) for hinting at using the `dir` target of\n  `skopeo` in\n  [#469](https://github.com/containers/skopeo/issues/469#issuecomment-465353019)\n- [@rhatdan](https://github.com/rhatdan) and the `skopeo` team for `skopeo`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolast%2Fstatic-container-registry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicolast%2Fstatic-container-registry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolast%2Fstatic-container-registry/lists"}