Sobes.tech
Junior

What are the key features that Docker is based on?

sobes.tech AI

Answer from AI

Key features of Docker:

  • Process isolation: Containers are inherently isolated from each other and from the host system. This is achieved through Linux kernel mechanisms such as namespaces (PID, NET, IPC, MNT, UTS) and cgroups (for limiting CPU, memory, I/O resources).

  • Images: A Docker image is an immutable, layered artifact that contains everything needed to run an application: code, libraries, dependencies, tools, and configuration files. Images are built on a "layered" basis, allowing reuse of common components and saving space.

  • Containers: A container is a runnable instance of an image. It is lightweight, portable, and contains the running application. Containers can be quickly started, stopped, moved, and scaled.

  • Dockerfile: A Dockerfile contains a set of instructions describing the process of building a Docker image. It is a declarative approach to image creation, ensuring reproducibility and automation of the build process.

    # Dockerfile example
    FROM alpine:3.14 // Base image
    RUN apk add --no-cache nginx // Install packages
    COPY html/ /usr/share/nginx/html/ // Copy files
    EXPOSE 80 // Open port
    CMD ["nginx", "-g", "daemon off;"] // Command to run container
    
  • Layered Filesystem: Docker uses Union File Systems (AUFS, OverlayFS) that allow creating images from layers. Each layer represents a set of changes compared to the previous layer. This feature enables quick image creation, layer caching, and efficient disk space usage.

  • Docker Registry (Registry/Hub): Docker registries (e.g., Docker Hub, GCR, ACR) are used to store and distribute Docker images. This facilitates sharing images among developers, teams, and environments.

  • Portability: Images and containers are designed to be portable. An image built on one platform can be run on any other platform where Docker is installed, without needing to reconfigure dependencies.

  • Fast startup: Starting a container is significantly faster than starting a virtual machine because there is no need to load a full operating system.

  • Efficient resource utilization: Containers use host system resources more efficiently than virtual machines, as they do not require dedicated CPU cores.