mini-docker is a minimal containerization project in Go. It demonstrates basic Docker principles using Linux namespaces and chroot for process isolation.
- OS: Linux (or a Linux environment like WSL2, Podman, or a VM)
- Go: 1.13+
- Privileges: Root (or privileged container mode)
Clone the repository:
git clone https://github.com/yourusername/mini-docker.git
cd mini-dockerFollow these steps to run the project:
git clone https://github.com/yourusername/mini-docker.git
cd mini-dockerThe project uses chroot for isolation, so you need to create a rootfs directory containing a minimal Linux environment. For example, you can use debootstrap:
sudo apt update -o Acquire::Check-Valid-Until=false
sudo apt install -y debootstrap
mkdir -p /path/to/rootfs
sudo debootstrap --arch=arm64 focal /path/to/rootfs http://ports.ubuntu.com/ubuntu-portsThen, move (or create a symbolic link to) the generated filesystem into the project directory if the project expects rootfs at the root.
To run the project directly from the source code, execute:
go run main.go run /bin/shThis command will create an isolated environment and run the /bin/sh command inside it.
If you want to test the project in a Linux environment using Podman, start a privileged container with the project mounted:
podman run --privileged -v "$(pwd):/app" -it ubuntu:20.04 /bin/bashInside the container, navigate to the /app directory and run:
go run main.go run /bin/sh