Docker Under the Hood
In this lesson, we look under the hood of Docker.
Before writing Dockerfiles and running ROS2 containers, you need to understand what Docker actually is and how it works.
Docker is often compared to a virtual machine, but it is not the same thing.
A virtual machine runs a complete guest operating system on top of a hypervisor.
Docker containers are lighter because they share the host operating system kernel and only package what the application needs: binaries, libraries, dependencies, and configuration.
This is why Docker is usually faster, lighter, and more practical for robotics development.
Why We Do This
In robotics, you often need to run several tools together:
ROS2 nodes, simulation tools, camera drivers, robot drivers, Python packages, C++ libraries, and sometimes hardware-specific software.
If you install everything directly on your system, your environment can become fragile.
Docker helps because it gives each application a controlled environment while still using the host machine efficiently.
Understanding this architecture is important because it explains both the power and the limits of Docker.
What You Will Learn
In this lesson, we cover the core concepts behind Docker:
- The difference between Docker containers and virtual machines
- The main Docker components
- What a container really contains
- What the Linux kernel does
- Why containers share the host kernel
- The limitations of kernel sharing
- Why CPU architecture matters
- How multi-architecture builds and emulation help solve compatibility problems
Docker vs Virtual Machines
A virtual machine includes:
- the application
- its binaries and libraries
- a full guest operating system
- a hypervisor layer
- the host operating system
- the physical infrastructure
This makes virtual machines powerful, but also heavier.
A Docker container includes:
- the application
- the binaries and libraries it needs
The container runs through the Docker daemon and shares the host operating system kernel.
This makes containers much lighter and faster to start.
For robotics, this matters because we often need responsive development environments, especially when working with simulation, hardware, or multiple tools at the same time.
Core Components of Docker
Docker is built around a few key components:
Docker CLI
The command-line tool you use to interact with Docker.
Docker Engine
The system that builds, runs, and manages containers.
Docker Images
The packaged environment. An image contains the filesystem, dependencies, libraries, and configuration needed to run your application.
Containers
A running instance of an image. If the image is the recipe, the container is the running application.
Docker Hub
A public registry where Docker images can be downloaded and shared.
In practice, you will use the Docker CLI to pull images, build images, and run containers.
What Is a Container?
A container is an isolated environment that runs an application with its required dependencies.
Inside a container, you usually have:
- the application
- binaries
- libraries
- configuration files
- runtime dependencies
But the container does not include a full operating system kernel.
Instead, it uses the kernel of the host operating system.
This is one of the main reasons Docker is lightweight.
In robotics, this means we can package a ROS2 application and its dependencies without creating a full virtual machine for every project.
What Is the Kernel?
The kernel is the core part of the operating system.
It connects software to hardware.
Your applications do not directly control the CPU, memory, network, USB devices, or file system. They ask the operating system kernel to manage those resources.
Docker containers share the host kernel.
This is what makes containers efficient, but it also creates an important limitation:
the container must be compatible with the host system and hardware architecture.
Kernel Sharing and Limitations
Because Docker shares the host kernel, containers are not completely independent like virtual machines.
This means architecture compatibility matters.
For example:
- your development laptop may use an
x86_64CPU - a Jetson device uses an
ARM64CPU
A container image built for x86_64 will not automatically run on ARM64.
This is very important in robotics because we often develop on a PC and deploy on Jetson, Raspberry Pi, or industrial edge computers.
Docker helps a lot, but you still need to understand the target architecture.
Solving Architecture Compatibility
There are two common ways to handle architecture differences:
Multi-architecture builds
You create Docker images for different platforms, for example:
docker buildx build --platform linux/amd64,linux/arm64
This allows you to prepare images for both desktop PCs and ARM-based devices.
Emulation
You can run an image for another architecture using an emulator, such as QEMU.
This is useful for testing, but it is usually slower than running natively.
In robotics, the practical rule is simple:
build your Docker image for the hardware where it will run.
Key Takeaways
- Docker containers are lighter than virtual machines because they share the host kernel.
- A Docker image is the packaged environment.
- A container is a running instance of an image.
- Docker helps isolate dependencies without duplicating a full operating system.
- The kernel connects software to hardware.
- CPU architecture matters when moving from PC to Jetson or other edge devices.
- Multi-architecture builds and emulation help when targeting different platforms.
Student Win
After this lesson, Docker should no longer feel like magic.
You now understand the basic architecture behind containers, why they are lighter than virtual machines, and why this matters for robotics.
- This gives you the foundation to start using Docker with more confidence when building ROS and ROS2 development environments.
0 comments