# 20 Docker Interview Questions & Answers to Rule Them All

Aced (formerly Exponent) publishes a public search API over its indexed pages; the guide is at https://www.aced.io/agents/agent-access.

Source: https://www.aced.io/blog/top-docker-interview-questions
Source observed: 2026-11-05T00:52:46.900Z
Last checked: 2026-11-05T00:52:46.9+00:00
Indexed: 2026-11-07T03:12:03.42+00:00

---

# 20 Docker Interview Questions & Answers to Rule Them All

**Software Engineering · Aced Team · Last updated a month ago**

We created this guide for software developers and engineers preparing for interviews involving Docker and containerized workloads. Docker helps developers build, run, update, and ship applications in containers. The guide covers practical concepts, commands, architecture, storage, networking, monitoring, and common interview prompts.

## Top 20 Docker interview questions

### 1. Describe a Docker container's lifecycle

A container lifecycle has five main phases; some phases may be skipped depending on the use case.

- **Create:** Instantiate a container from an existing image.

  ```bash
  docker create --name <container-name> <docker-image-name>
  ```

- **Run:** Start a container with `docker run`, either from a local image or an image pulled from a registry.

  ```bash
  docker run <container-name> # OR docker run <container-id> # OR docker run <repository-name/container-name:tag>
  ```

- **Pause/unpause:** Pause or resume a running container.

  ```bash
  # Pause
docker pause <container-name> # OR docker pause <container-id>
  # Unpause
docker unpause <container-name> # OR docker unpause <container-id>
  ```

- **Stop:** Shut down the desired container process.

  ```bash
  docker stop <container-name> # OR docker stop <container-id>
  ```

- **Delete:** Remove a container that is no longer needed. Use `-f` to force deletion.

  ```bash
  docker rm <container-name or container-id>
  # Delete forcefully
docker rm -f <container-name or container-id>
  ```

See the [Docker Reference documentation on Command-line interfaces (CLIs)](https://docs.docker.com/reference/?ref=exponent-blog.ghost.io).

### 2. What is the difference between virtualization and containerization?

[Virtualization](https://opensource.com/resources/virtualization?ref=exponent-blog.ghost.io) isolates physical hardware resources and simulates a separate computing unit at the hardware level. [Containerization](https://www.citrix.com/solutions/app-delivery-and-security/what-is-containerization.html?ref=exponent-blog.ghost.io) isolates the operating system and simulates a separate operating system at the OS level, abstracted from the host operating system.

### 3. What are Docker object labels?

[Docker object labels](https://docs.docker.com/config/labels-custom-metadata/?ref=exponent-blog.ghost.io) attach information such as the type and version of an image to Docker objects, including images, containers, volumes, networks, local daemons, swarm nodes, and swarm services.

### 4. What are Docker images?

A [Docker image](https://docs.docker.com/engine/reference/builder/?ref=exponent-blog.ghost.io) is a template or file containing an application and its dependencies. It supplies instructions for building a container and serves as the starting point for running one. A container is a running instance of an image. Images are read-only and comparable to snapshots in virtual-machine environments.

### 5. What is Docker Hub?

[Docker Hub](https://docs.docker.com/docker-hub/?ref=exponent-blog.ghost.io) is a remote image repository where Docker users create, develop, store, and distribute images with individuals or teams.

### 6. Explain the Docker architecture

Docker has three principal components:

- **[Docker client](https://docs.docker.com/get-started/overview/?ref=exponent-blog.ghost.io#the-docker-client):** The preferred interface for issuing commands. It communicates through the Docker API.
- **[Docker host](https://docs.docker.com/get-started/overview/?ref=exponent-blog.ghost.io#the-docker-daemon):** Contains the Docker daemon, which manages Docker objects such as images, volumes, and containers. The daemon listens for requests through the Docker API.
- **[Docker registries](https://docs.docker.com/get-started/overview/?ref=exponent-blog.ghost.io#docker-registries):** Store built images. The client communicates with registries through an API, together with the daemon, to push and pull images.

Docker uses a client-server architecture. A client can communicate with a daemon on the same machine or with a daemon on a remote Docker host.

### 7. What is a Dockerfile?

A [Dockerfile](https://docs.docker.com/engine/reference/builder/?ref=exponent-blog.ghost.io) contains instructions for building an image. Developers specify the code, dependencies, and tools to include. The resulting read-only image contains a consistent snapshot of code and dependencies for a particular time.

### 8. How do you find stored Docker volumes?

On Linux, stored Docker volumes can be found in `/var/lib/docker/volume`. Volumes persist data generated by running containers so it can be accessed and managed.

### 9. What are some basic Docker commands?

- **`docker --version`:** Displays information about the Docker version running on the host.
- **`docker ps`:** Lists running containers.
- **`docker ps -a`:** Lists running and exited containers.
- **`docker exec`:** Accesses a running container, commonly in interactive mode:

  ```bash
  docker exec -it <container-name or container-id> bash
  ```

- **`docker run`:** Creates a container from an existing image:

  ```bash
  docker run -it -d <docker-image>
  ```

- **`docker rm`:** Deletes stopped containers:

  ```bash
  docker rm <container-name or container-id> # OR
  # Delete image forcefully
docker rm -f <container-name or container-id>
  ```

### 10. How do you create a Docker container from an image?

Use `docker create` to create a container without starting it, then use `docker start` to start it:

```bash
# To create a docker image
docker create --name nginx_base -p 80:80 nginx:alpine
# Start created docker image
docker start nginx_base
```

### 11. How do you list all running containers?

Run `docker ps`.

### 12. How do you start, stop, and kill a Docker container?

- Start: `docker start <container-name or container-id>`
- Stop: `docker stop <container-name or container-id>`
- Kill: `docker kill <container-name or container-id>`

### 13. Can a Docker container be restarted automatically?

Yes. Docker provides restart policies that can be attached to a container:

- **`on-failure`:** Restarts a container if it exits because of a failure.
- **`unless-stopped`:** Does not restart a container after it is stopped, including when the Docker daemon restarts.
- **`always`:** Restarts a container after it stops.

Attach or change a policy with these commands:

```bash
# Start a container in detached mode and attach a policy
docker run --restart <insert-policy-here> <container-name or container-id>
# Change restart policy for an already running container
docker update --restart <insert-policy-here> <container-name or container-id>
# Change restart policy for all running containers
docker update --restart <insert-policy-here> $(docker ps -q)
```

See Docker's [restart-policy documentation](https://docs.docker.com/config/containers/start-containers-automatically/?ref=exponent-blog.ghost.io#use-a-restart-policy).

### 14. What is the difference between `COPY` and `ADD` in a Dockerfile?

Use `COPY` for standard local file or directory copying because it makes the operation explicit. `ADD` also copies files but supports downloading from remote URLs and automatically extracting TAR files.

Docker's [best practices for writing Dockerfiles](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/?ref=exponent-blog.ghost.io#add-or-copy) recommend using `curl` or `wget` with `RUN` for downloads and removing files when they are no longer needed. This avoids unexpected files being added to the image; use `ADD` only when necessary.

```dockerfile
COPY <source-directory> <destination-directory>
# <source> can be file, URL, or tarball.
ADD <source> <destination-directory>
# Using curl command with COPY to download a file
COPY . /data
RUN curl -SL https://example.com/big.tar.xz \
 | tar -xJC /data \
```

### 15. How will you monitor Docker in production?

Docker's [`docker stats`](https://docs.docker.com/engine/reference/commandline/stats/) command provides a live stream of container resource usage. [`docker events`](https://docs.docker.com/engine/reference/commandline/events/) displays real-time server events.

Docker also integrates with the open-source monitoring system [Prometheus](https://docs.docker.com/config/daemon/prometheus/?ref=exponent-blog.ghost.io). Docker can be configured as a Prometheus target, allowing Prometheus to scrape Docker-daemon metrics at regular intervals for analysis.

### 16. When should you run stateful or stateless applications in Docker containers?

A Docker container can be in one of four states: run, paused, exit, or restart. An application is **stateless** when it does not read or store information about its state between runtimes. A **stateful** application retains state between runs.

The appropriate choice depends on the use case. Applications that must persist session data are stateful. User interfaces that only permit GET operations can be stateless because they do not persist or query existing data.

### 17. Which default networks are available in Docker?

The [bridge network](https://docs.docker.com/network/bridge/?ref=exponent-blog.ghost.io) is Docker's default network driver. If no driver is specified, Docker creates a bridge network, and new containers connect to it unless another network is specified. User-defined bridge networks provide better isolation than the default bridge network.

### 18. What are the `ENTRYPOINT` and `CMD` instructions?

`[ENTRYPOINT](https://docs.docker.com/engine/reference/builder/?ref=exponent-blog.ghost.io#entrypoint)` sets the executable that runs when a container starts. A Dockerfile should contain only one `ENTRYPOINT`.

`[CMD](https://docs.docker.com/engine/reference/builder/?ref=exponent-blog.ghost.io#cmd)` supplies the default program executed when the container runs. When both are present, `CMD` is executed as part of the `ENTRYPOINT` command. An argument supplied through `docker run` or shell form overwrites `CMD`, while the `ENTRYPOINT` command remains.

### 19. What types of mounts are available in Docker?

Docker supports **volumes**, **bind mounts**, and **tmpfs mounts**.

- **[Volumes](https://docs.docker.com/storage/volumes/?ref=exponent-blog.ghost.io):** Managed by the Docker engine, created through Docker commands, and shareable between containers. On Linux, they are stored under `/var/lib/docker/volumes/`, isolated from the host, and retain data while a container is not running.
- **[Bind mounts](https://docs.docker.com/storage/bind-mounts/?ref=exponent-blog.ghost.io):** Mount a host file system path into a container. The container depends on the host's specified directory structure.
- **[Tmpfs mounts](https://docs.docker.com/storage/tmpfs/?ref=exponent-blog.ghost.io):** Temporary, memory-backed mounts. Their data is lost when the container stops and is stored in host memory rather than the file system.

### 20. Can you lose data when a container exits?

Data created inside a container remains there when the container exits. If the container is deleted, its data is deleted too. To create backups, make [container commits](https://docs.docker.com/engine/reference/commandline/commit/?ref=exponent-blog.ghost.io) and [save](https://docs.docker.com/engine/reference/commandline/save/?ref=exponent-blog.ghost.io) them as TAR files.

## Prepare with Aced

We are Aced, formerly Exponent: a learning platform for technology interviews in product management, engineering, and other disciplines. To continue preparing for software engineering interviews, you can:

- [Browse software engineer interview questions](https://www.aced.io/questions?role=swe&src=blog) and answers from real candidates.
- [Book time with a Software Engineer coach](https://www.aced.io/coaching?role=swe), including mock interviews, career coaching, and resume review. [Browse coaches](https://www.aced.io/coaching?role=swe&src=blog).
- [Create a free account](https://www.aced.io/signup?src=blog).

We state a **96% rating from 5,400 reviews** for our coaching offering on this page.

## Related courses

- [Software Engineering Interview Prep Course](https://www.aced.io/courses/software-engineering) — **5 courses, 41,700 students**. Covers mock interviews, frameworks, senior-candidate advice, data structures, algorithms, system design, people management, behavioral interviews, and more, with preparation for roles at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Image: [Software Engineering Interview Prep Course](https://images.ctfassets.net/x78yjrjc11pq/4VkuYewBHUFIVUS5oJDW5h/02e833439b1289f25f38f13f81cbdca3/adobe_stock_optimized.jpeg?w=800&h=800)
- [Amazon Software Development Engineer (SDE) Interview Course](https://www.aced.io/courses/amazon-sde-interview) — **5 courses, 4,600 students**. Covers data structures, algorithms, system design, detailed questions, mock interviews, and Amazon leadership principles. Image: [Amazon Software Development Engineer course](https://images.ctfassets.net/x78yjrjc11pq/13J85L9SUOG04YlmBQO22r/60eb5015cca36c6a178bbc0eb148571d/amazon_318003089b.png?w=800&h=800)

## Related blog posts

- [Microservices and distributed systems are unreliable. Here's what to do about it](https://www.aced.io/blog/microservices-and-distributed-systems-are-unreliable-heres-what-to-do-about-it) — 4 years ago, 1 min read.
- [Top 15 SQL Interview Questions and Answers (with Examples)](https://www.aced.io/blog/top-sql-interview-questions) — a month ago, 13 min read.
- [Top React Interview Questions for Experienced and Beginner Developers](https://www.aced.io/blog/top-react-interview-questions) — a month ago, 13 min read.
- [MongoDB Interview Questions and Answers For Experienced and Beginner Developers](https://www.aced.io/blog/mongodb-interview-questions-answers) — a month ago, 12 min read.

The article is written by [Joseph Eshiett](https://www.linkedin.com/in/joeshiett/?ref=exponent-blog.ghost.io), a DevOps practitioner and technical writer interested in cloud technologies, software development, and deployment processes.

---

[Read this page’s summary](https://www.aced.io/agents/api/public/v1/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fblog%2Ftop-docker-interview-questions&trace=t_679ff9ab98f3)

## Ask a follow-up about this page

Need a more specific answer? Ask the exact question you have. It returns a fresh, cited answer from Aced (formerly Exponent)’s knowledge base. No account or API key required.

Open this URL with your own question, URL-encoded. Include your question in q. All research inputs are optional; no account or setup.

`GET https://www.aced.io/agents/agent/faq?q={question}&trace=t_679ff9ab98f3`

[Tool guide and examples](https://www.aced.io/agents/agent-access) · [OpenAPI](https://www.aced.io/agents/api/public/v1/openapi.json) · [Page TLDR form](https://www.aced.io/agents/agent-tools/page-tldr?url=https%3A%2F%2Fwww.aced.io%2Fblog%2Ftop-docker-interview-questions). Opening a form does not execute a tool.