Serving my blog posts as containers

TIL 89 words #containers
I’d always assumed you needed container registry software to docker pull from. TIL: a webserver will do, podman pulling is just
GETsGETs (and some HEADs)
:
GET /v2/                              → 200 (any body)
GET /v2/<name>/manifests/<tag|digest> # content-type: the manifest's mediaType, e.g. application/vnd.oci.image.manifest.v1+json
GET /v2/<name>/blobs/<digest>         # content-type: anything (eg octet-stream )

To serve an image from a webserver you neeed to:

  1. Get the image into an OCI layout, either from local podman storage:
skopeo copy containers-storage:localhost/hello-world:latest oci:layout:latest

or from Docker Hub:

skopeo copy --format oci docker://docker.io/library/hello-world:latest oci:layout:latest
  1. copy the files to those paths:
r=site/v2/hello-world # the repo's URL path: /v2/<name>
mkdir -p $r/manifests $r/blobs # the two paths clients GET
touch site/v2/index.html # so we get a 200 on /v2/
for f in layout/blobs/sha256/*; do cp $f $r/blobs/sha256:${f##*/}; done # clients ask for sha256:<hex>, the layout stores sha256/<hex>
m=$(jq -r '.manifests[0].digest' layout/index.json) # the manifest's digest; the layout keeps it beside the layers
cp layout/blobs/sha256/${m#sha256:} $r/manifests/latest # pull by tag
cp layout/blobs/sha256/${m#sha256:} $r/manifests/$m # pull by digest, which clients also do

Upload site/ to any host that lets you set Content-Type on the manifests.

Long story shortnow you can read any of my posts via podman / docker for example this post:

podman run --rm jamesst.one/posts/oci-image-static-host
docker run --rm jamesst.one/posts/oci-image-static-host