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
这是什么?Bocker 是 Docker 的一个精简重新实现,用约 100 行 bash 代码编写,旨在展示容器核心功能的底层工作原理。
这是 Docker 的真正替代品,还是更像一个学习练习?它是一个 bash 脚本,利用 btrfs 快照、cgroups 和网桥等 Linux 底层机制来模拟 Docker 的命令行指令。它是一个介绍 Docker 内部原理的教学演示,而不是生产环境的容器运行时。
我该怎么让它运行起来?克隆仓库后直接运行 bocker 脚本,或者使用自带的 Vagrantfile 启动一个预配置好的虚拟机,其中所有必需的软件包和网络设置都已就绪。
运行前需要先安装哪些东西?你需要安装 btrfs-progs、curl、iproute2、iptables、libcgroup-tools、util-linux >= 2.25.2 和 coreutils >= 7.5,还需要将一个 btrfs 文件系统挂载到 /var/bocker,并创建一个名为 bridge0、IP 为 10.0.0.1/24 的网桥。
Docker 的哪些功能还没有实现?数据卷容器、数据卷和端口转发目前尚未实现,docker build 的支持也仅是非常有限的实现。
在我平时用的电脑上运行安全吗?不安全。Bocker 以 root 身份运行,会直接改写你的网络接口、路由表和防火墙规则,因此 README 建议即使你的系统已满足前置条件,也要在虚拟机中运行它。
Bocker 支持哪些 Docker 命令?它实现了 build(有限支持)、pull、images、ps、run、exec、logs、commit、rm 和 rmi,并通过 cgroups 提供基础的网络和配额支持。
为什么 Bocker 需要 btrfs 文件系统?它利用 btrfs 的写时复制快照来实现容器分层和镜像提交,这与 Docker 本身可以将 btrfs 用作存储驱动的方式类似。
不配置自己的 Linux 机器,有没有简单的试用方法?有。自带的 Vagrantfile 会构建一台虚拟机,其中所有必需的软件包、文件系统和网桥都已设置好。
What are similar projects?ProxmoxVE, distrobox, webhook, hadolint, skopeo, Linux-, Proxmox, neofetch
Creator
p8952
Size
0.4 MB
Stars
12.7K
Updated
CommitAug 12
Age
11y
Commits · 90 Days