dclone-phase2.mov
dclone is a minimal container runtime built in Go for learning how containers work under the hood.
This is not a Docker replacement. It is a small educational project focused on Linux processes, namespaces, chroot, mounts, cgroups, and basic container networking.
- Runs a command inside an Alpine root filesystem
- Creates a child process with Linux namespaces
- Isolates hostname, process IDs, and mount view
- Uses
chrootso the child process sees the rootfs as/ - Mounts
/procand/sysinside the container - Supports an experimental
--memoryflag using cgroups v2 - Connects the container to the host through a Linux bridge and veth pair
sudo /tmp/dclone run /tmp/alpine-rootfs /bin/shInside the container:
hostname
cat /etc/os-release
ls /
exitMemory limit example:
sudo /tmp/dclone run --memory 64m /tmp/alpine-rootfs /bin/shNote: cgroups support depends on the Linux environment. In Lima on macOS, writing to memory.max may fail if the VM does not allow memory controller writes.
Network demo:
sudo /tmp/dclone run -p 8080:80 /tmp/alpine-rootfs /bin/shInside the container:
mkdir -p /www
echo "hello from dclone container" > /www/index.html
httpd -f -p 80 -h /wwwFrom another Lima terminal:
curl 10.88.0.2Expected:
hello from dclone container
Note: direct access to the container IP works. localhost:8080 port publishing is still experimental.
dclone run /tmp/alpine-rootfs /bin/sh
|
v
Parent process parses the CLI command
|
v
Parent starts a child process with new Linux namespaces
|
v
Child process re-enters the same binary using /proc/self/exe
|
v
Child sets hostname, chroots into the rootfs, mounts proc/sys
|
v
Parent connects the child network namespace to dclone0
|
v
/bin/sh runs inside the isolated environment
This project must run on Linux. If you are on macOS, use a Linux VM such as Lima.
limactl start dclone-vm
limactl shell dclone-vmBuild:
cd /Users/itsmanan/Computer-Science/Backend/dclone
go build -o /tmp/dcloneRun:
sudo /tmp/dclone run /tmp/alpine-rootfs /bin/sh- Go
- Cobra
- Linux namespaces
chroot- Linux mounts
- cgroups v2
- Linux bridge and veth networking
- Lima for running Linux on macOS
- Educational project only
- No image pulling
- No daemon
- No container IDs or lifecycle tracking
localhost:8080style port publishing is experimentalstop.goexists as a placeholder and is not wired into the CLI
Manan