Skip to the page

Docker for Node and Next.js apps · mid

Docker in CI and deploys

In CI you build the image once with BuildKit, tag it with the git commit (plus a version), scan it, push it to a registry and deploy that exact image (ideally by digest) to every environment, never a mutable 'latest'.

The notes

What you must know

  • docker buildx build with cache export/import (registry or GitHub Actions cache) keeps CI builds fast.
  • Tags: an immutable one per build (git SHA) plus readable ones (v1.4.0, main). Deploy by SHA tag or digest so a rollback is a redeploy of an old tag.
  • Image reference format: registry/repository:tag@digest. Without a registry, Docker Hub is assumed; official images live under library/ (node = docker.io/library/node).
  • Multi-architecture images (linux/amd64 and linux/arm64) matter for AWS Graviton and Apple Silicon.
  • Docker Hub limits pulls: 100 per 6 hours for anonymous users (per IP), 200 for free personal accounts. Log in, mirror images, or use a registry pull-through cache (ECR) in CI.
  • Scan in the pipeline and fail on critical CVEs; build-time secrets via --secret, never --build-arg.

The red pen

Common traps: mistake → fix

  • Mistake: Deploy :latest everywhere

    Fix: you cannot tell what is running or roll back reliably; latest is just a moving tag.

  • Mistake: Rebuild per environment

    Fix: staging and production may get different dependencies; build once, promote the same image.

Easy to hard

Questions interviewers ask, easy to hard

  1. How does your CI build and ship Docker images?
  2. How do you tag images and roll back?
  3. CI builds suddenly fail with 'toomanyrequests'. Why, and what do you do?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview