WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Docker · Basic · question 2 of 100

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

📕 Buy this interview preparation book: 100 Docker questions & answers — PDF + EPUB for $5

In Docker, an image is a lightweight, standalone, and executable package that contains everything needed to run an application, including the code, libraries, and runtime environment. An image is essentially a snapshot of a Docker container’s filesystem at a particular point in time. Docker images are typically built from a Dockerfile, which is a script that specifies the steps needed to create an image.

A Docker container, on the other hand, is a runtime instance of a Docker image. A container is an isolated environment that includes everything needed to run an application, such as the image, the application’s code, libraries, and runtime environment. Docker containers run on top of a Docker engine, which provides the necessary runtime environment to execute the application.

Here are some key differences between a Docker image and a Docker container:

Immutable vs. Mutable: Docker images are immutable, which means that they cannot be changed once they are created. Any changes made to a Docker container are not persisted and will be lost when the container is stopped. This means that images can be shared and reused across different environments, whereas containers are specific to a particular runtime instance.

Build time vs. Runtime: Docker images are created at build time, whereas Docker containers are created at runtime. An image can be used to create multiple containers, each running in a separate instance.

Lightweight vs. Resource-Intensive: Docker images are lightweight and portable, while Docker containers are resource-intensive and run on top of a Docker engine. This means that multiple containers can run on a single host system, whereas each image requires its own dedicated space.

Persistence: Docker images can be stored in a Docker registry and shared across multiple hosts, while Docker containers are ephemeral and do not persist changes made at runtime.

For example, let’s say you are a developer building a web application that consists of a web server and a database. You can create a Docker image for the web server and another image for the database. These images can then be used to create Docker containers that run the application. Each container would run in an isolated environment with its own copy of the image and the application’s code, libraries, and runtime environment. If you need to make changes to the application, you would update the image and create a new container from it.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Docker interview — then scores it.
📞 Practice Docker — free 15 min
📕 Buy this interview preparation book: 100 Docker questions & answers — PDF + EPUB for $5

All 100 Docker questions · All topics