Your DevOps study space

Real explanations. Videos with tests. Fresh exams every time. Keep the streak alive and watch the XP stack up.

Registries and image security · Docker Docs · StackwisePlanDevOps Registries and image security · Docker Docs · StackwiseCodePython Registries and image security · Docker Docs · StackwiseBuildDocker Registries and image security · Docker Docs · StackwiseTestDevOps Registries and image security · Docker Docs · StackwiseReleaseGit Registries and image security · Docker Docs · StackwiseDeployKubernetes Registries and image security · Docker Docs · StackwiseOperateLinux Registries and image security · Docker Docs · StackwiseMonitorDevOps

Pick a topic

Eight tracks, each with docs, a cheat sheet, videos and tests.

How it works

One loop, repeated until it sticks.

Jump back in

Picked up from where you left off.

Free forever

Your DevOps journey starts with one click.

Sign in with Google or GitHub to open every chapter, video, test and challenge. Your progress is saved wherever you learn.

Registries and image security

Building an image is half the job. It has to live somewhere every machine can pull it from, you need to know exactly which version is running, and it shouldn't ship with known holes or secrets baked in. This chapter covers registries, tags versus digests, scanning, and the habits that make an image hard to attack.

What a registry holds

A registry is a server that stores images: Docker Hub, GitHub Container Registry (GHCR), Amazon ECR, Google Artifact Registry, or one you run yourself. Inside it, each repository holds the versions of one image. The full name of an image tells Docker where to find it:

ghcr.io/demee/shop-api:1.4.0
└──┬──┘ └─┬─┘ └──┬───┘ └─┬─┘
registry  owner  repository  tag

nginx:1.27          # no registry part means Docker Hub, and the owner "library" (official images)

Every image also has a digest: sha256: followed by a hash of its contents. The tag is a name you choose; the digest is calculated from what's inside.

Tags move, digests don't

A tag is just a label pointing at a digest, and anyone who can push can move it. nginx:1.27 today and nginx:1.27 next month are usually different images, because the maintainers rebuild it with security fixes. latest moves all the time. A digest can never point at anything else.

ghcr.ioregistrydemeeownershop-apirepository:1.4.0tagone image name:1.4.0today:latestsha256:4ff1...c39efixed: computed from the contentssha256:9a07...51d2next month's rebuildpoints atcan move to
A tag is a sticky note you can move. A digest is the image's fingerprint. Deploy by SHA or version tag, and pin digests when you need the exact same bytes every time.
$ docker buildx imagetools inspect nginx:1.27      # shows the digest the tag points at right now
Name:      docker.io/library/nginx:1.27
Digest:    sha256:4ff1...c39e
$ docker pull nginx@sha256:4ff1...c39e             # pull exactly that image, forever
$ docker images --digests                          # digests of what you already have

In a FROM line you can pin both, so the file stays readable and the build stays repeatable: FROM python:3.12-slim@sha256:.... Tools like Dependabot can bump the digest for you when a new base image comes out.

Pushing to a registry

Tag the image with the registry's name, log in, push. The three you'll meet most:

# Docker Hub
$ docker login                                     # opens a browser or asks for an access token
$ docker tag shop-api:dev demee/shop-api:1.4.0
$ docker push demee/shop-api:1.4.0

# GitHub Container Registry: log in with a personal access token that has write:packages
$ echo "$GHCR_TOKEN" | docker login ghcr.io -u demee --password-stdin
$ docker tag shop-api:dev ghcr.io/demee/shop-api:1.4.0
$ docker push ghcr.io/demee/shop-api:1.4.0

# Amazon ECR: the repository must exist, and the password comes from the AWS CLI
$ aws ecr create-repository --repository-name shop-api
$ aws ecr get-login-password --region eu-central-1 \
    | docker login --username AWS --password-stdin 123456789012.dkr.ecr.eu-central-1.amazonaws.com
$ docker tag shop-api:dev 123456789012.dkr.ecr.eu-central-1.amazonaws.com/shop-api:1.4.0
$ docker push 123456789012.dkr.ecr.eu-central-1.amazonaws.com/shop-api:1.4.0

Use --password-stdin so the token never lands in your shell history. In GitHub Actions you don't need a personal token for GHCR at all: the built-in GITHUB_TOKEN works once the workflow has permissions: packages: write (the CI/CD pipeline chapter shows the whole job). Docker Hub limits how often anonymous users can pull, so log in on CI machines and servers too.

A tagging scheme that tells you what's running

  • The commit SHA on every image CI builds: shop-api:3f9c2a1. You can always trace a running container back to the exact code.
  • A version for releases: shop-api:1.4.0, plus 1.4 and 1 if people pull you by major version.
  • Never deploy latest. It says nothing about what's inside, two servers can end up running different things under the same name, and rolling back to "the previous latest" is impossible.

Scanning for known vulnerabilities

Every package in an image (the OS packages from the base image and your app's libraries) might have published security holes, called CVEs. A scanner reads what's installed and checks it against vulnerability databases. Two common ones are Trivy (open source) and Docker Scout (built into Docker Desktop and the CLI):

$ trivy image shop-api:1.4.0
shop-api:1.4.0 (debian 12.7)
Total: 23 (UNKNOWN: 0, LOW: 14, MEDIUM: 6, HIGH: 3, CRITICAL: 0)

│ Library  │ Vulnerability  │ Severity │ Installed │ Fixed Version │
│ libssl3  │ CVE-2024-XXXXX │ HIGH     │ 3.0.14-1  │ 3.0.15-1      │

$ docker scout cves shop-api:1.4.0                 # the same idea with Docker Scout

# No Trivy installed? Run it as a container:
$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock aquasec/trivy image shop-api:1.4.0

Read the report by the Fixed Version column. A HIGH with a fix available usually just means "rebuild on a newer base image"; one with no fix yet is something to know about, not something you can patch today. In CI, fail the build only on what you can act on:

$ trivy image --severity HIGH,CRITICAL --ignore-unfixed --exit-code 1 shop-api:1.4.0

Scan again on a schedule too. An image that was clean when you built it collects new CVEs as they're discovered, even though nothing in it changed.

Give attackers less to work with

  • Small base images. -slim, alpine or distroless images contain fewer packages, so fewer CVEs and fewer tools an attacker can use after breaking in. Multi-stage builds (Docker chapter 3) keep compilers out of the final image.
  • Don't run as root. Add a user and switch to it with USER, as in Docker chapter 3.
  • Lock the container down at run time when the app allows it:
    $ docker run --read-only --tmpfs /tmp \
        --cap-drop ALL --security-opt no-new-privileges:true \
        shop-api:1.4.0
    A read-only filesystem means a break-in can't drop files; dropping Linux capabilities and blocking privilege escalation stops root-only tricks.
  • Never put secrets in an image. Anything you COPY or ENV into a layer can be read by anyone who can pull the image, even if a later layer deletes it. Pass secrets at run time (environment variables, mounted files, a secrets manager). If the build itself needs one, for example a token for a private package registry, use a BuildKit secret, which is never stored in a layer:
    # Dockerfile
    RUN --mount=type=secret,id=npmrc,target=/root/.npmrc npm ci
    
    $ docker build --secret id=npmrc,src=$HOME/.npmrc -t shop-api:dev .

SBOMs and signatures, briefly

A software bill of materials (SBOM) is a list of every package in an image, so that when the next big vulnerability is announced you can search your SBOMs instead of rescanning everything: docker scout sbom shop-api:1.4.0 or trivy image --format cyclonedx --output sbom.json shop-api:1.4.0.

Signing proves an image came from your pipeline and wasn't swapped. Cosign (from the Sigstore project) can sign images in CI using the workflow's own identity, with no long-lived key to guard, and a cluster can be set up to refuse unsigned images. You won't need it on day one, but you'll hear about it in interviews.

Common mistakes

  • "denied: requested access to the resource is denied" on push: not logged in to that registry, the image isn't tagged with your namespace (docker push shop-api:1.4.0 tries Docker Hub's library), or the token lacks write permission.
  • "no basic auth credentials" with ECR: the login expired. ECR passwords last 12 hours, so log in again.
  • Pulled an old image without noticing: a server already had app:latest cached. Deploy by SHA or version tag, or pass --pull always / docker compose pull first.
  • A secret in an old layer: deleting the file in a later layer doesn't help. Remove it from the build, rebuild, and rotate the secret, because it's already out.
  • Ignoring the scanner because the list is long: filter to HIGH and CRITICAL with a fix available, fix those by updating the base image, and work down from there.

Questions

Pick an answer. Get it wrong and you can try again right away, no waiting. 10 questions per topic - pick a filter below, then use Recreate questions for a fresh set on that topic.

Fresh questions every time

Exam

A mixed test across the whole site, shuffled so you never know which topic comes next. When you submit, every mistake comes with the reason and a jump to the exact moment in the video that explains it.

30 questions 6 topics 20 minute limit Up to 70 XP
1–4 answer · ←→ move
History

Essay

0 / 200-250 words
Sample answer
History
0:00 / 0:00
Not started

on YouTube
Subscribe

Topic progress

Activity

Achievements

Settings

Your profile and your account.

Profile details

* Required. Saved in this browser until you sign in.

Letters, numbers, dots, dashes and underscores.
0 / 160

Account

Checking…

App

Install Stackwise on your phone or computer. It opens in its own window from your home screen, and the Docs and cheat sheets you've opened keep working without internet.

Only admins can see this

Dashboard

Sign-ups, activity, messages and reviews in one place.

Prove it

Certificates

Pass a topic's test and get a certificate with its own public page you can share or add to LinkedIn. Each test is 10 questions drawn at random and graded on the server; you need 8 right, you have 15 minutes, and you get one try per topic a day.

From first command to production

Linux for DevOps

A path through Linux the way DevOps engineers use it: ten stages, every command explained with its flags, examples, real output and mistakes, the combinations engineers chain together, and incidents worked through step by step. Practise everything in a safe lab folder.

Before the interview

Interview prep

Questions that come up in real DevOps interviews, with the kind of answer that lands. Say yours out loud first, then compare. Each one links to the chapter that goes deeper.

    Private to you

    My notes

    Everything you wrote down while watching and reading, in one place. Saved to your account, never shown to anyone.