← All articles

docker · technology · containers

Docker Base Images are not Operating Systems

A note on what OS-based container images contain, and where their Linux kernel comes from.

I have been using Docker for almost eight years, maybe more, and I never really thought about what gets packaged as an image. Mostly, I cared about the app I was packaging and whether it ran properly after deployment.

Recently, while checking some notes from my learning days, I got stuck on a question that I am sure many of us have had: we almost always use a base image in our Dockerfile, so what does that base image actually contain?

For example:

FROM ubuntu:26.04

RUN apt-get update && apt-get install -y curl && apt-get clean

CMD ["bash"]

Here, I am using Ubuntu as the base image. If I build and run this on my Mac, does Docker bring the entire Ubuntu operating system into the image?

If so, I would expect the image to be several gigabytes, because a desktop Ubuntu installation is large. But that is not what I see. So I wanted to clarify this for myself, and share what I learned.

For this post, I am talking about OS-based images such as Ubuntu. I will touch on runtime images like python:slim near the end.

Let’s build and inspect the image

First, I built the example image:

cd /path/to/project
docker build -t test-container-ubuntu.v1 .

docker build output

Then I checked the image:

docker images --filter reference="*.v1*"

docker image list output

Next, I started a container and opened a shell inside it:

docker run -d --name test-container test-container-ubuntu.v1 sleep infinity
docker exec -it test-container bash

root@ca5e114daab1:/# ls -l

docker container run

I can see a Linux directory structure inside the container, even though my laptop is a Mac.

I also checked the image and container sizes:

docker images --filter reference="*.v1*"
docker ps -s --filter name=test-container

docker container and image size

In my output, the image was around 185 MB, and the container’s writable size was 0 B. Those numbers are much smaller than a full desktop Ubuntu installation. So what exactly did I package?

What is inside the image?

The important distinction is that an Ubuntu container image gives us an Ubuntu user space filesystem. It does not include and boot its own Ubuntu kernel.

That filesystem can include directories and files such as /bin, /etc, /lib, /usr, shell tools, system libraries, package metadata, and—in this example—curl. These are the programs and files that run inside the container. The kernel is supplied by the Linux environment running the container engine.

A simplified view of an operating system is:

Part What it does Is it in this Ubuntu image?
Kernel Manages processes, memory, devices, and system calls No; supplied by the Linux host or VM
User space Programs, libraries, shells, and files such as /usr, /bin, and /etc Yes; this is the main content of the image

So FROM ubuntu:26.04 does not mean “boot a complete Ubuntu computer.” It means “start with a filesystem containing Ubuntu user-space files.” The container process uses the kernel of the Linux environment that runs Docker.

Why does the container show a Linux filesystem on my Mac?

Docker containers use Linux kernel features, including namespaces and control groups, for isolation and resource management. macOS does not have a Linux kernel, so Docker Desktop runs a lightweight Linux virtual machine in the background. The Docker Engine and Linux containers run inside that VM.

Windows has a similar arrangement for Linux containers: Docker Desktop uses a Linux environment, commonly WSL 2 or a Linux VM. On a Linux machine, the container engine can use the host’s Linux kernel directly.

That means when I run the Ubuntu container on my Mac, it is not talking to the macOS kernel. It is using the Linux kernel inside Docker Desktop’s VM. The Ubuntu user-space files come from the image; the kernel comes from the Linux VM.

VM vs. container

It helps to compare containers with virtual machines:

Virtual machine Linux container
What is isolated? A virtual computer, including its own guest OS and kernel Processes and their view of the filesystem, network, and other resources
Kernel Each VM boots its own kernel Containers on the same Linux host share that host kernel
What is packaged? A full guest OS plus applications User-space files, libraries, and application code
Typical footprint Larger; often measured in gigabytes Often smaller; depends on the image and its layers
Startup Boots an operating system Starts a process; usually much faster than booting a VM

A VM virtualizes hardware. A container uses operating-system features to isolate processes. When Docker Desktop is running on macOS or Windows, there is a VM underneath the Linux containers, but the containers still share the Linux kernel inside that VM.

What do the image and container size numbers mean?

In my output, the image was about 185 MB. That represents the image’s stored layers as reported by Docker. The exact number depends on the image version, architecture, and Docker’s reporting; it is not a promise that the complete local disk usage will always be exactly that amount. Images can also share layers, so adding up image sizes does not always equal disk space used.

When I ran docker ps -s, the writable size for this container was 0 B. Docker adds a thin writable layer on top of the image layers when it starts a container. In this example, I had not written or downloaded any files inside the container, so that layer had no additional data to report.

If Docker also shows a virtual size, that is the image’s read-only data plus the container’s writable layer. Containers created from the same image share its read-only layers, so their virtual sizes should not be added together to calculate actual disk use.

The image itself remains unchanged when a container runs. Changes made inside a container go into its writable layer. If the container is removed, that writable layer is removed too; data that needs to survive should be stored in a Docker volume or another persistent location.

Where does the kernel come from in different environments?

The answer depends on where Docker Engine is running:

Environment Where the Linux container gets its kernel
Mac with Docker Desktop The Linux VM managed by Docker Desktop
Windows with Docker Desktop The Linux environment managed by Docker Desktop, commonly WSL 2 or a Linux VM
Linux with Docker Engine The host's Linux kernel
Cloud VM running Linux The Linux kernel in that VM
Kubernetes or another managed container platform The Linux kernel on the worker node that runs the container; the provider manages the underlying infrastructure

An Ubuntu container can run on a Fedora host because the container brings Ubuntu’s user-space filesystem, while the Fedora machine supplies the Linux kernel. The container runtime uses Linux isolation features to run the process. The kernel does not need to be the same distribution as the user-space files, though CPU architecture and kernel compatibility still matter.

Are VMs still needed?

Yes. Containers did not replace virtual machines. They solve different problems and are often used together.

VMs are useful when you need a separate operating system or kernel, when you need to run another OS, or when you want a stronger isolation boundary between workloads. Containers are useful for packaging and running applications consistently, starting short-lived environments, and scaling services.

In many cloud setups, the container runs on a worker node that is itself a virtual machine. The cloud provider manages that VM and the physical server beneath it. Some platforms hide those details, but a Linux kernel still has to run the container process.

When would I use a container or a VM?

Use case Often a good fit Why
Web services and APIs Containers Package the app and its user-space dependencies together; scale or replace instances easily
CI/CD jobs Containers Run repeatable, short-lived build and test environments
Applications needing another OS or kernel VMs A VM boots its own guest operating system and kernel
Applications needing kernel modules or OS-level control VMs or a dedicated host Containers share the host kernel and cannot provide a separate one
Databases and stateful services Either, depending on operations Storage, performance, backup, and operational requirements matter more than a blanket rule
Untrusted workloads Depends on the required isolation A VM can provide a stronger boundary, but configuration and other security controls still matter

This is not a rule that databases must run in VMs or that containers are always the right choice. The workload, data, isolation needs, and team operations determine the fit.

What about runtime images like python:slim?

A runtime image such as python:slim includes a user space with Python and the libraries and files it needs. It saves us from installing Python from scratch in our Dockerfile. It still does not provide its own running kernel.

The kernel still comes from the same place as before: the Linux host, a Linux VM on a Mac or Windows machine, or the worker node in a cloud environment.

Some images are more minimal still. For example, a scratch-based image can start with no general-purpose Linux user-space filesystem at all. But the process it runs still needs a compatible kernel supplied by the environment.

In Short

An Ubuntu image is not a complete Ubuntu machine. It packages Ubuntu user-space files. The Linux kernel comes from wherever the Docker Engine is running: directly from a Linux host, or from a Linux VM when using Docker Desktop on macOS or Windows.

That is why an image can be much smaller than a full OS installation, and why an Ubuntu container can run on a Fedora machine. The image supplies the user space; the Linux environment supplies the kernel.

References