Topic lessonTopic: Container foundations
Containers for beginners: images, runtime, hosts and persistent data
A container runs application processes in a separated environment. An image packages the files used for that execution; it is not itself a running application. Use two API containers made from one image to understand Linux hosts, networking and data lifetimes.
Distinguish images from containers, host responsibilities and data lifetimes, then identify conditions to check before execution.
A process is a running program; the host provides its execution environment. This is a fixed reading exercise with no installation or container execution. Windows-specific isolation modes are outside this Linux-focused example.
One image can create separate executions
- Image A → Container ACreate from the image
- Image A → Container BReuse the same image
- Container A → Linux hostRuns on the host
- Container B → Linux hostRuns on the same host in this example
- Image A
- Application files and libraries
- Container A
- API execution; its own writable layer
- Container B
- Separate execution from the same image
- Linux host
- Provides the kernel and runtime environment
| Object | Contents or role | What it does not establish |
|---|---|---|
| Image | Application files, libraries and defaults; changed content produces another image. | Whether it is running or external data and secrets are correctly supplied. |
| Container | An execution environment with processes and a writable layer. | Whether it has the same state as another container or durable data. |
| Host and runtime | Execute processes and provide resources and separation. | Whether all applications have enough capacity or are secure. |
Virtual machines and containers separate different layers
The kernel is the OS core managing processes, memory and devices. Ordinary Linux containers share the host kernel. Linux distribution files inside an image do not mean every container starts its own independent Linux kernel.
| Aspect | Virtual machine | Ordinary Linux container |
|---|---|---|
| OS core | Guest OS has its own kernel. | Shares the host kernel. |
| Separation | Runs an OS on a virtualized machine. | Separates process-visible resources and related state. |
| Combination | A VM can host containers. | Containers do not necessarily replace VMs. |
Linux namespaces separate views of resources; cgroups account for and limit resource use. Configuration, privileges, shared mounts and kernel vulnerabilities still matter. Containerization is not permission to run arbitrary untrusted software safely.
Separate stopping, recreating and deleting data
A container’s writable layer records its changes. In Docker it normally remains when the container is merely stopped, but deleting and recreating the container does not retain that layer. Check automatic removal settings and the actual storage destination.
| Location | What to check when recreating |
|---|---|
| Temporary file only in container A | Removing A’s writable layer can lose it. |
| An explicitly retained named volume | Has a separate lifetime; check volume deletion and retention conditions. |
| External database or object storage | Review data permissions, retention and consistency separately from container replacement. |
When containers use the same volume or external database, changes to shared data can affect other users. Separate containers do not automatically mean independent data, and a volume alone does not establish recoverability.
Check execution conditions even with the same image
| Condition | How to reason about it |
|---|---|
| OS and CPU architecture | Do not assume Linux/amd64-only content runs unchanged on ARM64. |
| Configuration and secrets | Supply environment-specific settings and secrets separately; do not embed them in images. |
| Networking and authorization | Check the path to an API and permission to access its data. |
| CPU, memory and storage | Do not assume desktop capacity or data lifetimes match another environment. |
In AWS, ECR stores and distributes images, ECS manages task and service execution, and Fargate is one compute option. These map shared concepts to AWS; containers do not require AWS.
- Identify the image’s purpose, source, version and OS/CPU requirements.
- Review external connections, permissions and secret delivery.
- Separate temporary, durable and shared data.
- Define resource limits, stopping/replacement and health checks.
Practise distinguishing artifacts and execution
Choose an option to see the result and explanation.
Check, then explain in your own words
- Identify the image, two containers and host in the diagram.
- Explain temporary-file, volume and external-database lifetimes.
- Check platform, permissions and configuration, then study image identity.
Check your understanding: Besides the image, what should you inspect before recreating a container?
Runtime conditions, permissions and connectivity, resources, and data location/lifetime.
The same image does not guarantee the same running state, external data or reachability. Inspect artifacts and execution responsibilities separately.
Sources and conditions checked
Primary references are collected here with their scope, conditions and corresponding sections. Independent expert review and live-environment validation have not been performed.
- Docker: what is a container?Checked:
Scope and conditionsLinux process environments and VM/host layers; not unconditional isolation or compatibility. Documentation review, not live AWS verification.
Used in this lessonOne image can create separate executions Virtual machines and containers separate different layers Practise distinguishing artifacts and execution
- Docker: what is an image?Checked:
Scope and conditionsImage files/layers versus execution; changed content produces a different artifact. Documentation review, not live AWS verification.
Used in this lessonOne image can create separate executions Practise distinguishing artifacts and execution
- Docker Engine securityChecked:
Scope and conditionsNamespaces, cgroups, privileges, daemon and shared-host conditions. Documentation review, not live AWS verification.
Used in this lessonOne image can create separate executions Virtual machines and containers separate different layers Check execution conditions even with the same image
- Docker Desktop for LinuxChecked:
Scope and conditionsDocker Desktop for Linux VM and container execution host; do not generalize every desktop backend. Documentation review, not live AWS verification.
Used in this lessonVirtual machines and containers separate different layers
- Docker volumesChecked:
Scope and conditionsWritable-layer and volume lifetimes, sharing and deletion conditions. Documentation review, not live AWS verification.
Used in this lessonSeparate stopping, recreating and deleting data Check execution conditions even with the same image Practise distinguishing artifacts and execution
- Docker multi-platform buildsChecked:
Scope and conditionsOS/CPU compatibility and manifest/index selection; distinguish Linux host and desktop OS. Documentation review, not live AWS verification.
Used in this lessonCheck execution conditions even with the same image Practise distinguishing artifacts and execution
- Amazon ECR overviewChecked:
Scope and conditionsImage storage/distribution versus application execution; private-repository permissions. Documentation review, not live AWS verification.
Used in this lessonCheck execution conditions even with the same image
- Amazon ECS task definitionsChecked:
Scope and conditionsDefinition revisions versus running tasks; registration is not an update of existing executions. Documentation review, not live AWS verification.
Used in this lessonCheck execution conditions even with the same image
- Amazon ECS clustersChecked:
Scope and conditionsLogical grouping versus compute; current Fargate, EC2 and Managed Instances options. Documentation review, not live AWS verification.
Used in this lessonCheck execution conditions even with the same image