A Docker implementation written in Golang designed for educational purposes. Gocker enables you to create and manage container, pull images, and more. We do not recommend using it in production environments, and suggest running it inside a virtual machine instead.
Gocker runs only on Linux-based system with version 3.10 or higher of the Linux kernel.
Required packages:
libcgroup-tools
Required configuration:
- A btrfs filesystem mounted under
/var/gocker
(configurable) - A cgroup filesystem mounted under
/sys/fs/cgroup/
(configurable) if not already the case
git clone https://github.com/Ninroot/gocker
cd gocker/
make
cd build/
./gocker --help
When using Gocker, you need to be specific when pulling or running an image, as it does not have the same magic as Docker does. For example, use pull amd64/alpine
instead of just pull alpine
.
# gocker requires root privileges
sudo su
# image for ARM-based system (like mac running on Apple silicon)
./gocker pull arm64v8/alpine
./gocker run arm64v8/alpine:latest /bin/sh
./gocker image rm arm64v8/alpine
- file system: via chroot, gives the illusion the container can navigate inside a different distro.
- PID: via namespace, isolates the processes running inside a container with processes of the host / other containers.
- Mount: via namespace, isolates the mounts to the container. This prevents the mounts from being visible from the host.
- UTS: via namespace, allows to set a new hostname inside the container without affecting the hostname of the host.
Great souces to learn Docker:
- How Docker Works - Intro to Namespaces
- Containers the hard way: Gocker: A mini Docker written in Go - Detailed article explaining another Docker implementation in Golang (not related to this project despite a similar name)
- Bocker - Docker implemented in around 100 lines of bash
- Containers From Scratch with Golang