Skip to main content

What is a container in Docker?

A container in Docker is a running instance of a Docker image that operates as an isolated process on the host system. A container has its own filesystem, network, environment variables, and resources, but it uses the same operating system kernel as the host.

Key properties of a container

  1. Isolation A container's processes cannot see the processes and filesystem of other containers (namespaces).
  2. Its own filesystem A container gets a filesystem based on the image, plus a top writable layer for its own changes.
  3. Lightness and speed Containers start in a fraction of a second and consume fewer resources than virtual machines.
  4. Ephemerality A container lives as long as its main process runs. After it stops, its state is usually not preserved (unless a volume is used).

Main idea

A container is an isolated process started from an image, which looks like a separate environment but shares the OS kernel with the host.

If needed, I can also briefly compare a container and a virtual machine in a single table.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.