A Docker container can be isolated, patched, and carefully configured while still starting from an image you cannot fully trust. The safest Docker deployments treat every image, package, build step, and registry as part of a software supply chain that needs verification.

This guide explains the practical controls that matter most for a homelab or small production server: trusted images, digest pinning, least privilege, vulnerability scanning, software bills of materials, and provenance. It is a natural follow-up to our Docker basics guide and homelab security rules.

Why image tags are not enough

A tag such as nginx:latest is a movable label. The publisher can point it at a newer image tomorrow, and a compromised registry account could point it at something malicious. Even version-looking tags can change, depending on the publisher’s release process.

A digest identifies the exact image manifest. Pinning an image with image@sha256:... makes the deployment reproducible: the host pulls the content represented by that digest or fails. Docker’s documentation recommends digest validation when critical base images must remain known-good.

Tags are still useful for discovering updates, but the production or long-lived Compose file should record the digest after the image has been reviewed.

Start with a trusted image source

Prefer official images, vendor-maintained images, or projects with a transparent release process. Before using an image, check its documentation, update history, supported versions, exposed ports, default users, and published security policy.

Avoid images that:

  • Have no source repository or maintainer identity
  • Download arbitrary scripts during startup
  • Run as root without explaining why
  • Bundle unrelated utilities and services
  • Have not been updated for a long period
  • Use an unclear or copied project name

A smaller image is not automatically safer, but fewer packages generally mean fewer components to patch and audit. The right goal is a minimal, maintained image that contains everything the application needs and little else.

Pin images by digest

A Compose service can use a tag for readability and a digest for immutability:

services:
  app:
    image: ghcr.io/example/app:1.4.2@sha256:REPLACE_WITH_REVIEWED_DIGEST
    restart: unless-stopped
    read_only: true
    security_opt:
      - no-new-privileges:true
    cap_drop:
      - ALL

Replace the placeholder only after inspecting the exact image. Keep a short record of when the digest was approved and which release it represents. When updating, pull the new candidate, scan it, test it, and change the digest deliberately rather than allowing an unattended tag update.

Do not copy a digest from an untrusted blog post. Resolve it from the registry or the project’s release documentation, then verify that the architecture and variant match your host.

Reduce runtime privileges

Supply-chain security is only one layer. If an image is compromised, runtime restrictions can reduce the damage.

Use a non-root user when the application supports it. Drop Linux capabilities, enable no-new-privileges, keep the filesystem read-only where practical, and mount only the directories the service needs. Never mount /var/run/docker.sock into an untrusted application: access to the Docker socket is effectively broad control over the host.

Expose only required ports and put administrative interfaces behind a private network or VPN. For a home server, Tailscale can provide access without publishing every service to the internet.

Generate and review an SBOM

An SBOM, or software bill of materials, lists the components inside an image. It helps answer a basic incident-response question: “Which deployed services contain this vulnerable library?” Without an inventory, searching a server full of containers becomes guesswork.

Generate an SBOM during CI or before deployment, store it with the build record, and rescan when a vulnerability is announced. The SBOM does not prove that an image is safe; it gives you visibility into what must be patched.

A practical workflow is:

  1. Pull the candidate image by its immutable digest.
  2. Scan the operating-system packages and application dependencies.
  3. Generate an SPDX or CycloneDX SBOM.
  4. Record the digest, scan date, and exceptions.
  5. Deploy only after reviewing critical findings.

Do not treat every scanner result as an exploitable issue, but do not dismiss critical findings without documenting why the affected code is unreachable or mitigated.

Verify provenance and signatures

A digest proves which bytes were pulled; provenance explains how those bytes were produced. For important services, prefer projects that publish signed releases, build attestations, or reproducible build information.

A mature CI pipeline should identify the source commit, workflow, builder, dependencies, and image digest. Signature verification can then ensure that the image came from the expected publisher rather than merely from a registry account with a familiar name.

For a small homelab, you may not implement a full admission controller. You can still keep a deployment checklist: source repository, release version, digest, scan result, SBOM location, and rollback digest.

Keep updates deliberate

Digest pinning must not become an excuse to stop patching. Subscribe to release and security notifications for the projects you run. Review updates on a schedule, test them, and replace the pinned digest.

Keep at least one known-good previous image reference so you can roll back. Back up application data separately from containers: containers should be replaceable, while databases, uploads, and configuration secrets need tested backups. Our backup and homelab guidance covers the operational side of that process.

A practical checklist

Before deploying a new container, ask:

  • Is the image source and maintainer trustworthy?
  • Is the exact digest recorded?
  • Does the service need root or extra capabilities?
  • Can the filesystem be read-only?
  • Are ports and mounts minimal?
  • Has the image been scanned?
  • Is an SBOM available?
  • Can the service be updated and rolled back safely?
  • Are secrets outside the image and out of version control?

FAQ

Should every Docker image be pinned by digest? For production and important long-lived services, yes. For quick experiments, tags are convenient, but review the image before promoting it.

Does an SBOM make an image secure? No. It improves visibility and helps responders find affected components; it is one control in a wider process.

Is running as a non-root user enough? No. Combine it with capability dropping, restricted mounts, network limits, patching, and backups.

Can I use Docker Compose with digest-pinned images? Yes. Compose accepts an image reference containing both a tag and a digest, making the intended release readable while the digest controls the exact content.

What should I do first? Replace unreviewed floating tags, remove unnecessary privileges, and create an inventory of the images already running on your server.

Container security is not a single switch. A trusted source, immutable image reference, visible contents, constrained runtime, and repeatable update process together make Docker deployments much easier to defend and recover.

Sources