Câu hỏi phỏng vấn Docker
Câu hỏi

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

Câu trả lời

The difference between a Docker image and a container is fundamental to understanding how Docker works. Here’s a detailed explanation:

Docker Image

A Docker image is a read-only template that contains the instructions for creating a Docker container. It includes everything needed to run an application: the code, runtime, libraries, environment variables, and configuration files. Docker images are immutable, meaning they cannot be changed once created. If modifications are needed, a new image must be built from the updated instructions. Images are often built from a Dockerfile, which is a script containing a series of commands to assemble the image. Images can be stored in repositories like Docker Hub and can be pulled to create containers[1][3][6][10].

Docker Container

A Docker container is a runnable instance of a Docker image. It is a lightweight, standalone, and executable package that includes everything needed to run the application, isolated from the host system and other containers. Containers are created from images and can be started, stopped, moved, and deleted. Unlike images, containers are mutable; they can be modified during runtime, and these changes can be saved by creating a new image from the container’s current state. Containers share the host system’s kernel but run in isolated user spaces, making them more efficient than virtual machines[1][3][6][7].

Key Differences

  1. Nature:

    • Image: Immutable, read-only template.
    • Container: Mutable, runnable instance of an image.
  2. Function:

    • Image: Serves as a blueprint for creating containers.
    • Container: The actual environment where the application runs.
  3. Creation:

    • Image: Built from a Dockerfile or pulled from a repository.
    • Container: Created from an im...
junior

junior

Gợi ý câu hỏi phỏng vấn

middle

What is Hypervisor?

junior

What does Containerization mean?

expert

Can you explain a relationship between container runtime and container orchestration?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào