Why Docker
What is Docker?
Docker is a tool that creates a lightweight, isolated environment (called a container) that runs on your computer. Think of it as a small, self-contained computer inside your computer.
Why Docker for Pintos?
Pintos is a toy operating system that needs special tools to compile and run:
Cross-compiler toolchain - Special programs that can compile code for 32-bit x86 computers (even though you're probably on a 64-bit machine)
QEMU or Bochs - Programs that simulate an old x86 computer so Pintos can run on it
Installing these tools manually is complicated and different on each operating system. Docker solves this by packaging everything into one image.
What Happens Inside Docker?
When you run the Docker container:
You get a Ubuntu 18.04 Linux environment with all the Pintos tools pre-installed
Inside this container, you can:
Navigate to your Pintos code
Run
make
to compile PintosUse
pintos
command to boot Pintos in QEMUDebug and test your code
What is Mounting?
Mounting is how Docker connects your computer's files to the container:
docker run -it --rm --name pintos \
--mount type=bind,source=/path/to/your/pintos,target=/home/PKUOS/pintos \
pkuflyingpig/pintos bash
This command:
source=/path/to/your/pintos
- Points to your Pintos folder on your computertarget=/home/PKUOS/pintos
- Where that folder appears inside the containerCreates a shared workspace - Changes you make on your computer appear instantly in the container, and vice versa
The Workflow
On your computer: Edit Pintos code with your favorite editor (VS Code, Vim, etc.)
In Docker container: Compile and run your code
Changes sync automatically - No need to copy files back and forth
Why Not Just Install Tools Directly?
Different OS requirements - Windows, Mac, and Linux need different installation steps
Version conflicts - The tools might conflict with other software on your system
Complex setup - Installing cross-compilers manually is error-prone
Consistency - Docker ensures everyone has the exact same environment
Benefits
Same environment everywhere - Works the same on Windows, Mac, and Linux
Clean isolation - Doesn't mess up your computer
Easy reset - If something breaks, just restart the container
Instant file sharing - Your code and the container are always in sync
Docker lets you focus on learning Pintos instead of fighting with tool installation and environment setup.
Last updated