An image is a recipe plus all the ingredients, frozen. A container is a running dish made from it. You can run many containers from one image. Docker kills “it works on my machine”: everyone runs the exact same environment.
Say it like this in the interview
“An image is an immutable, layered template; a container is a running instance with its own writable layer, process and network namespace. Docker gives consistent environments from laptop to production, isolation, and fast deployment.”
Copy the dependency list first and install, then copy your code. Docker caches each step, so changing code doesn’t reinstall all packages. Multi-stage builds leave build tools out of the final image, and running as a non-root user limits damage if hacked.
FROM node:24-alpine AS deps
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
FROM node:24-alpine
WORKDIR /app
ENV NODE_ENV=production
COPY --from=deps /app/node_modules ./node_modules
COPY . .
USER node
EXPOSE 3000
CMD ["node", "server.js"]
Say it like this in the interview
“Small base image, dependency manifests copied before source for layer caching, npm ci, multi-stage build to keep the final image small, a .dockerignore excluding node_modules and .env, non-root user, and the exec form of CMD so signals reach the process.”
A container’s files are temporary. When the container is removed, its writable layer goes with it. Data must live in a volume outside the container.
Say it like this in the interview
“Data was in the container’s writable layer. Databases need a named volume, like -v mysql_data:/var/lib/mysql, or a bind mount. In production I’d usually use a managed database anyway.”
One file that describes several containers (app, database, cache) and how they connect, so you can start everything with one command.
Say it like this in the interview
“compose.yaml defines services, networks, volumes, environment and healthchecks. docker compose up runs the whole stack, which is great for local development and simple deployments.”
Each Dockerfile instruction creates a layer. If nothing changed in a step, Docker reuses the cached layer. Change an early step and everything after rebuilds.
Say it like this in the interview
“Layers are cached by instruction and inputs. Put rarely-changing steps first, like installing dependencies from lock files, and frequently changing source code last. Combine RUN commands to reduce layers and clean caches in the same step.”
Smaller images have fewer holes. Don’t run as root, don’t bake in secrets, and scan for vulnerabilities.
Say it like this in the interview
“Minimal base images like distroless or alpine, multi-stage builds, a non-root user, no secrets in images (use runtime secrets), pinned versions, vulnerability scanning with Trivy or Docker Scout, read-only filesystems and dropped capabilities where possible.”
Inside a container, localhost means the container itself, not your computer or the database container.
Say it like this in the interview
“Each container has its own network namespace. In Docker Compose, services reach each other by service name, like db:5432, on the shared network. To reach the host, host.docker.internal. I also check the app waits until the database is healthy, using depends_on with a healthcheck.”
Pod: the smallest unit, one or more containers running together.
Deployment: the manager that says “always keep 3 copies of this pod running” and handles rolling updates.
Service: a stable address and load balancer in front of pods, which come and go.
Say it like this in the interview
“Pods run containers; Deployments manage ReplicaSets for desired replica count, rolling updates and rollbacks; Services give stable DNS and load balancing to changing pods, while Ingress handles external HTTP routing. Config goes in ConfigMaps and Secrets; readiness and liveness probes tell Kubernetes when pods are healthy.”
kubectl describe pod my-pod # events, exit codes, OOMKilled?
kubectl logs my-pod --previous # logs of the crashed attempt
In simple words
The container starts, crashes, Kubernetes restarts it, it crashes again… Find out why it crashes.
Say it like this in the interview
“describe for events and the exit code. Exit code 137 often means OOMKilled, so raise memory limits or fix the leak. logs --previous for the crashed container’s output. Common causes: missing env vars or secrets, wrong command, failing liveness probe, or a dependency not reachable.”
Both feed configuration into pods. Secrets are meant for sensitive values, but by default they’re only base64-encoded, not encrypted.
Say it like this in the interview
“ConfigMaps for non-sensitive config, Secrets for credentials, mounted as env vars or files. Enable encryption at rest, restrict RBAC, or use external secret managers.”