bocker README

The project's README from github.com/p8952/bocker. As one markdown file: README.md.

Bocker

Docker implemented in around 100 lines of bash.

Prerequisites

The following packages are needed to run bocker.

Because most distributions do not ship a new enough version of util-linux you will probably need to grab the sources from here and compile it yourself.

Additionally your system will need to be configured with the following:

For ease of use a Vagrantfile is included which will build the needed environment.

Even if you meet the above prerequisites you probably still want to run bocker in a virtual machine. Bocker runs as root and among other things needs to make changes to your network interfaces, routing table, and firewall rules. I can make no guarantees that it won't trash your system.

Example Usage

$ bocker pull centos 7
######################################################################## 100.0%
######################################################################## 100.0%
######################################################################## 100.0%
Created: img_42150

$ bocker images
IMAGE_ID        SOURCE
img_42150       centos:7

$ bocker run img_42150 cat /etc/centos-release
CentOS Linux release 7.1.1503 (Core)

$ bocker ps
CONTAINER_ID       COMMAND
ps_42045           cat /etc/centos-release

$ bocker logs ps_42045
CentOS Linux release 7.1.1503 (Core)

$ bocker rm ps_42045
Removed: ps_42045

$ bocker run img_42150 which wget
which: no wget in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)

$ bocker run img_42150 yum install -y wget
Installing : wget-1.14-10.el7_0.1.x86_64                                  1/1
Verifying  : wget-1.14-10.el7_0.1.x86_64                                  1/1
Installed  : wget.x86_64 0:1.14-10.el7_0.1
Complete!

$ bocker ps
CONTAINER_ID       COMMAND
ps_42018           yum install -y wget
ps_42182           which wget

$ bocker commit ps_42018 img_42150
Removed: img_42150
Created: img_42150

$ bocker run img_42150 which wget
/usr/bin/wget

$ bocker run img_42150 cat /proc/1/cgroup
...
4:memory:/ps_42152
3:cpuacct,cpu:/ps_42152

$ cat /sys/fs/cgroup/cpu/ps_42152/cpu.shares
512

$ cat /sys/fs/cgroup/memory/ps_42152/memory.limit_in_bytes
512000000

$ BOCKER_CPU_SHARE=1024 \
	BOCKER_MEM_LIMIT=1024 \
	bocker run img_42150 cat /proc/1/cgroup
...
4:memory:/ps_42188
3:cpuacct,cpu:/ps_42188

$ cat /sys/fs/cgroup/cpu/ps_42188/cpu.shares
1024

$ cat /sys/fs/cgroup/memory/ps_42188/memory.limit_in_bytes
1024000000

Functionality: Currently Implemented

† bocker init provides a very limited implementation of docker build

Functionality: Not Yet Implemented

License

Copyright (C) 2015 Peter Wilmott

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

bocker (p8952/bocker)

Searching Database…

12.7K ·GitHub
What is this?Bocker is a minimal reimplementation of Docker written in roughly 100 lines of bash, built to demonstrate how core container functionality works under the hood.
Is this a real replacement for Docker or more of a learning exercise?It's a bash script that mimics Docker's CLI commands using Linux primitives like btrfs snapshots, cgroups, and network bridges — an educational demo of Docker internals, not a production container runtime.
How do I get it running?Clone the repo and run the bocker script directly, or use the included Vagrantfile to spin up a preconfigured VM with all the required packages and network setup already in place.
What do I need installed before I can run it?You need btrfs-progs, curl, iproute2, iptables, libcgroup-tools, util-linux >= 2.25.2 and coreutils >= 7.5, plus a btrfs filesystem mounted at /var/bocker and a network bridge called bridge0 with IP 10.0.0.1/24.
What parts of Docker are missing?Data volume containers, data volumes, and port forwarding aren't implemented yet, and the docker build support is described as only a very limited implementation.
Is it safe to run on my regular machine?No — Bocker runs as root and directly rewrites your network interfaces, routing table, and firewall rules, so the README recommends running it inside a VM even if your system already meets the prerequisites.
Which Docker commands does Bocker support?It implements build (limited), pull, images, ps, run, exec, logs, commit, rm, and rmi, plus basic networking and quota support via cgroups.
Why does Bocker need a btrfs filesystem?Btrfs's copy-on-write snapshots are used to implement container layers and image commits, similar to how Docker itself can use btrfs as a storage driver.
Is there an easy way to try it without configuring my own Linux box?Yes, the included Vagrantfile builds a virtual machine with all the required packages, filesystem, and network bridge already set up.
What are similar projects?ProxmoxVE, distrobox, webhook, hadolint, skopeo, Linux-, neofetch, Proxmox
Creator
p8952
Size
0.4 MB
Stars
12.7K
Updated
CommitAug 12
Age
11y
Commits · 90 Days