Kahibaro
Discord Login Register

What is a container

Conceptual View: A Container in One Sentence

A container is a lightweight, isolated runtime environment that packages an application together with everything it needs to run (its file system, libraries, and configuration), while sharing the host operating system kernel with other containers.

It is:

Key Characteristics of a Container

1. Isolated but Not Separate Machines

A container is process-level isolation, not a full separate computer.

From inside the container, it looks like you have:

But under the hood:

You will see how containers differ from virtual machines in another chapter; here, the important idea is that containers are isolated views over shared kernel resources.

2. A Complete Runtime Environment

A container is not just a running process; it brings its own runtime environment:

This environment is defined by a container image, which you will see later, but for now:

Analogy:

3. Immutable Base + Ephemeral Runtime

Containers encourage an immutable infrastructure style:

Direct consequences:

4. Predictable and Portable

A container is designed to make software behave the same across:

This works because the container includes the application’s own dependencies and environment:

Everything else travels with the container image, so:

Portability has practical limits (e.g., CPU architecture, kernel features), but for most cloud-native use cases, containers are highly portable.

5. Resource-Constrained Units of Work

A container is a bounded unit of work:

On platforms like OpenShift:

6. Minimal by Design

Containers are ideally small and focused:

Practical implications:

The single-process focus enables:

7. Standardized Packaging Format

While different tools exist, most modern containers follow Open Container Initiative (OCI) standards:

From a conceptual standpoint:

You don’t need the low-level details here; what matters is that a container is:

What a Container Is *Not*

To avoid confusion, it helps to be explicit about what containers are not:

Lifecycle of a Container (High-Level)

Without going into orchestration (that’s for Kubernetes/OpenShift chapters), the basic container lifecycle is:

  1. Image is available:
    • Built from a definition (e.g., Dockerfile, BuildConfig).
    • Stored in a container registry.
  2. Container is created:
    • The runtime:
      • Sets up namespaces and cgroups.
      • Prepares the container filesystem from the image layers.
      • Applies configuration (env vars, volumes, ports).
  3. Container is started:
    • The main process specified by the image (ENTRYPOINT/CMD) runs.
    • From inside, it behaves as if it has its own small OS environment (but shares the kernel).
  4. Container runs:
    • Handles requests, does computations, etc.
    • Emits logs to stdout/stderr.
    • May read/write data to:
      • Its own ephemeral layer (lost when removed).
      • Attached persistent storage or external services (durable).
  5. Container stops:
    • The main process exits (successfully or due to an error).
    • Or it is terminated by the platform (e.g., scale down, node drain).
  6. Container is removed:
    • The ephemeral runtime state and temporary filesystem changes are discarded.
    • The image remains in the registry for future use unless explicitly removed.

In OpenShift and Kubernetes:

Why Containers Matter for OpenShift

OpenShift is a container platform. Understanding what a container is clarifies:

Later chapters will:

For this chapter, the key takeaway is:

A container is a lightweight, portable, isolated runtime environment for an application, created from a container image, sharing the host OS kernel, and designed to be ephemeral, resource-constrained, and easy to deploy consistently across environments.

Views: 19

Comments

Please login to add a comment.

Don't have an account? Register now!