← Back to Blog
Docker Interview Questions for DevOps Engineers (2026)
Docker14 min read·Mar 28, 2026
By InterviewDrill Team

Docker Interview Questions for DevOps Engineers (2026)

Docker interviews test whether you understand containers at the system level — not just how to run docker run. Here are the questions that separate junior from senior answers.


The Question That Every Senior Panel Asks

"Your container works fine locally but fails in production. How do you debug it?"

Most candidates say: "Check the logs."

What a strong answer looks like:

1. Verify image consistency: Is the same image tag being deployed? Never use latest in production — pin to a digest or specific version tag

2. Compare environment variables: Production env vars differ from local. Check for missing secrets, wrong endpoints, or misconfigured feature flags

3. Check resource limits: Local Docker has no limits. Production Kubernetes has CPU/memory limits. OOMKilled containers look like crashes

4. Inspect network mode: Local uses bridge by default. Production may use host, overlay, or a custom CNI. DNS resolution differs between environments

5. Verify volume mounts: File paths and permissions that work locally may fail in production due to read-only filesystems or different user IDs

6. Run the production image locally with production env vars: docker run --env-file prod.env


Core Concepts

1. What is the difference between a Docker image and a container?

An image is a read-only template — a snapshot of a filesystem and metadata (entrypoint, exposed ports, environment variables). It's immutable.

A container is a running instance of an image. It adds a writable layer on top of the image's read-only layers. Multiple containers can run from the same image simultaneously.

Analogy: Image is the class definition. Container is the instantiated object.


2. Explain Docker layers and how they affect image size

Every instruction in a Dockerfile creates a new layer. Layers are cached and shared between images.

FROM node:18-alpine           # layer 1: base image
WORKDIR /app                  # layer 2: working directory
COPY package*.json ./         # layer 3: package files
RUN npm ci                    # layer 4: dependencies (expensive)
COPY . .                      # layer 5: application code
CMD ["node", "server.js"]     # layer 6: entrypoint

Why this order matters: Docker caches layers. If you COPY application code before npm ci, any code change invalidates the npm cache and reinstalls all dependencies. The order above only reinstalls dependencies when package.json changes.

Reducing image size:


3. What is a multi-stage build and when do you use it?

# Stage 1: Build
FROM golang:1.21 AS builder
WORKDIR /app
COPY . .
RUN go build -o server .

# Stage 2: Runtime
FROM alpine:3.18
COPY --from=builder /app/server /server
EXPOSE 8080
CMD ["/server"]

Result: The final image contains only the compiled binary and Alpine (~8MB), not the Go toolchain (~800MB).

Use when: Compiled languages (Go, Rust, Java, C++), or when your build process requires tools not needed at runtime.


4. How does Docker networking work?

Default networks:

Custom bridge networks (recommended):

docker network create my-app
docker run --network my-app --name db postgres
docker run --network my-app --name api my-api-image
# api can now reach db at http://db:5432

Custom networks enable automatic DNS resolution by container name. Default bridge network does not.


5. What is the difference between CMD and ENTRYPOINT?

ENTRYPOINT: The command that always runs. Cannot be overridden with arguments to docker run (but can be overridden with --entrypoint).

CMD: Default arguments to ENTRYPOINT, or the default command if no ENTRYPOINT. Overridden by anything passed to docker run.

ENTRYPOINT ["python", "app.py"]
CMD ["--port", "8080"]

docker run myimage → runs python app.py --port 8080

docker run myimage --port 9090 → runs python app.py --port 9090

Shell vs exec form:


6. How do you secure Docker containers?

Image security:

Runtime security:

Secrets:


7. What is the difference between docker stop and docker kill?

docker stop:

docker kill:

Why it matters: Applications need SIGTERM to clean up connections, finish in-flight requests, and flush buffers. Always use docker stop for production containers. Make sure your application handles SIGTERM correctly — this is a common interview follow-up.


8. How do you reduce Docker build time in CI/CD?

Typical result: 10-minute builds reduced to 2-3 minutes with proper caching.


Practice These Questions Live

InterviewDrill.io has a Docker & Containers track — Joshua asks real production scenarios, scores your answer, and shows you the ideal response. First session free → interviewdrill.io

Reading helps. Practicing wins interviews.

Practice these exact questions with an AI interviewer that pushes back. First session completely free.

Start Practicing Free →