Q1
Why can COPY . . BEFORE RUN npm ci inside a Dockerfile eliminate Docker layer caching on every single line edit?
Docker caches layers top-down until a file checksum changes. Copying the whole source tree first invalidates npm ci / pip install whenever *any* source file changes! Copy package*.json first -> RUN npm ci -> COPY . . afterwards.
Q2
Why does running Node.js or Python as PID 1 inside a Docker shell form (CMD node server.js) ignore SIGTERM during docker stop / Kubernetes rollouts?
Shell form wraps commands in /bin/sh -c, which fails to forward SIGTERM down to node—forcing Docker/K8s to wait 10–30s then forcefully SIGKILL active requests! Use exec form CMD ["node", "server.js"] or tini/dumb-init.
Q3
How do Multi-Stage Docker builds shrink an 800 MB Node/Go image down below 80 MB AND reduce CVE vulnerability scans?
Build tools (gcc, TypeScript compilers, Maven, devDependencies) stay strictly inside the disposable builder stage; only the compiled binary/bundle copies into a tiny alpine or distroless runtime image.
Q4
Why does RUN apt-get update on a separate line above RUN apt-get install -y curl break Dockerfiles months later?
Docker caches the apt-get update layer with stale package metadata indefinitely! Always chain RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/* in one RUN.
Q5
In Git CI/CD workflows, how does git rebase onto main create cleaner bisect history than repetitive git merge—yet why must you NEVER rebase shared public main commits?
Rebasing rewrites commit hashes onto new parents; rebasing pushed commits shared by teammates forces divergent histories and destructive force-pushes. Rebase local feature branches freely; never rewrite shared main.
Q6
What is the key architectural difference between Blue-Green vs Canary deployments during database schema migrations?
Both Blue-Green and Canary run old v1 and new v2 app code simultaneously against the shared DB! Therefore, DB migrations MUST be backward-compatible (Expand-Contract pattern: add new nullable columns first, deploy v2, clean old columns later)—never drop/rename columns directly while v1 is still live!
Q7
Why does putting ADD instead of COPY in a Dockerfile pose subtle build unpredictability?
ADD secretly auto-extracts .tar archives and fetches remote URLs over the network (uncached/unverified), whereas COPY strictly and transparently copies local build context files.
Q8
What is the difference between Ansible (push-based agentless) vs Terraform (declarative stateful IaC), and why do mature DevOps pipelines combine both?
Terraform provisions and tracks cloud infrastructure resources via state files (VPCs, VMs, EKS clusters), while Ansible configures OS packages, hardening, and services inside running machines.
Q9
Why is latest Docker image tag an anti-pattern in production Kubernetes manifests?
:latest is mutable—node A pulls yesterday's image while node B autoscales with today's pushed digest, breaking rollback determinism and causing ImagePullBackOff / skewed bugs. Always pin immutable Git SHA tags or @sha256: digests.
Q10
How does GitOps (ArgoCD / Flux) prevent configuration drift compared to imperative kubectl apply from CI runners?
GitOps agents run *inside* the cluster pulling signed manifests continuously from Git, automatically reconciling manual hotfix drift back to Git's desired state without giving external CI servers root cluster credentials.