Layers

Layers

Naming scheme

Docker Hub

Images and layers


Image Manifest

Layers

Image configuration

Demo: Layers

Preparation

Upload image to local registry:

docker run -d -p 5000:5000 registry:2
docker build --tag localhost:5000/hello-world-java .
docker push localhost:5000/hello-world-java

Investigate layers locally

docker history hello-world-java

Demo: Image Manifest

Download image manifest:

curl \
  -sL \
  -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
  http://localhost:5000/v2/hello-world-java/manifests/latest \
| jq

Demo: Image Configuration

Download image configuration:

curl \
  -sL \
  -H "Accept: application/vnd.docker.container.image.v1+json" \
  http://localhost:5000/v2/hello-world-java/manifests/latest \
| jq

Demo: Download image layer

DIGEST=$(
  curl \
    -sL \
    -H "Accept: application/vnd.docker.container.image.v1+json" \
    http://localhost:5000/v2/hello-world-java/manifests/latest \
  | jq --raw-output '.layers[-1].digest'
)

curl \
  -sL \
  -H "Accept: application/vnd.docker.image.rootfs.diff.tar.gzip" \
  http://localhost:5000/v2/hello-world-java/blobs/${DIGEST} \
| tar -tvz

Demo: Verifying a layer’s digest

DIGEST=$(
  curl \
    -sL \
    -H "Accept: application/vnd.docker.container.image.v1+json" \
    http://localhost:5000/v2/hello-world-java/manifests/latest \
  | jq --raw-output '.layers[-1].digest'
)

curl \
  -sL \
  -H "Accept: application/vnd.docker.image.rootfs.diff.tar.gzip" \
  http://localhost:5000/v2/hello-world-java/blobs/${DIGEST} \
| sha256sum

Demo: Determining the content length

DIGEST=$(
  curl \
    -sL \
    -H "Accept: application/vnd.docker.container.image.v1+json" \
    http://localhost:5000/v2/hello-world-java/manifests/latest \
  | jq --raw-output '.layers[-1].digest'
)

curl \
  -sL \
  -H "Accept: application/vnd.docker.image.rootfs.diff.tar.gzip" \
  http://localhost:5000/v2/hello-world-java/blobs/${DIGEST} \
| wc -c

Registries

Usage

Further reading

Demo: Registries

Tagging images remotely

# Download manifest from old name
MANIFEST=$(curl -sL \
    -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
    localhost:5000/v2/hello-world-java/manifests/latest
)

# Push manifest with new name
curl -X PUT \
  -H "Content-Type: application/vnd.docker.distribution.manifest.v2+json" \
  -d "${MANIFEST}" \
  localhost:5000/v2/hello-world-java/manifests/new

# Test
docker pull localhost:5000/v2/hello-world-java/manifests/new