Docker and CI/CD Interview Questions and Answers
Containers and images, Dockerfile and layer caching, multi-stage builds, volumes and networks, Docker Compose, CI pipelines in GitHub Actions and GitLab CI, deployment strategies, Kubernetes basics and supply-chain security.
225 questions for Docker and CI/CD interviews with answers and explanations - Junior, Middle and Senior levels. Sample questions, online quizzes and coding tasks.
- Docker
- Compose
- GitHub Actions
- Deploys
- Kubernetes
Questions by level
Junior
Core concepts and syntax · 50 questions
Middle
Practice, nuances and optimization · 50 questions
Senior
Architecture, internals, edge cases · 50 questions
Sample questions
A few questions from each level with the correct answer and an explanation.
Docker and CI/CD · Junior
- How does a container differ from a virtual machine?
Correct answer: It shares the host kernel instead of running its own OS
Containers are isolated processes on the host kernel (namespaces and cgroups), so they start in milliseconds and use little memory. A VM boots a whole guest OS on virtual hardware.
- What is the difference between an image and a container?
Correct answer: An image is a read-only template; a container is a running instance of it
Like a class and its objects: one image can start many containers. Each container adds its own thin writable layer on top of the image.
- What is a Dockerfile?
Correct answer: A text file with the steps to build an image
Each instruction (
FROM,COPY,RUN,CMD...) describes a build step.docker buildexecutes them and produces an image. - What does
FROM node:22-alpinedo in a Dockerfile?Correct answer: Sets the base image that the build starts from
Every build starts from a base image, here the official Node.js 22 image on Alpine Linux. Your instructions add layers on top of it.
Docker and CI/CD · Middle
- What is the main benefit of a multi-stage build?
Correct answer: Build tools stay in earlier stages; the final image has only runtime files
A
builderstage installs dev dependencies and compiles; the final stage copies only the output withCOPY --from=builder. Images get smaller and safer. - Why does this Dockerfile reinstall all dependencies on every code change?
``
dockerfile COPY . . RUN npm ciCorrect answer: Any file change invalidates
COPY . ., sonpm cireruns tooCache invalidation cascades: once a layer changes, every later layer is rebuilt. Copy
package.jsonand the lockfile, runnpm ci, then copy the rest. - Why combine
apt-get updateandapt-get installin oneRUN?Correct answer: A cached
updatelayer would install packages from a stale indexIf
updateis its own cached layer, a later change to the install line reuses an old package index. Also clean/var/lib/apt/listsin the sameRUN. - Why does
RUN rm -rf /tmp/buildin a later layer not shrink the image?Correct answer: Earlier layers still contain the files; deletion only hides them
Layers are additive. Clean up in the same
RUNthat created the files, or use a multi-stage build so temporary files never reach the final image.
Docker and CI/CD · Senior
- 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.
- 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.
- 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.
- 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.
Coding tasks
Write your solution right in the browser, and tests check it instantly. JavaScript interview classics (debounce, deepClone, Promise.all, an LRU cache), TypeScript tasks on generics, narrowing and utility types checked by the real compiler, Node.js backend logic (middleware, rate limiters, job queues), SQL queries in real PostgreSQL, and React components and hooks like a todo list, tabs, useDebounce and useInterval.
Open tasks →