Compare commits

..

No commits in common. "master" and "v0.1" have entirely different histories.
master ... v0.1

14 changed files with 120 additions and 298 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
.vagrant/ .vagrant/
base-image/
util-linux/

View File

@ -1,5 +1,5 @@
# Bocker # Bocker
Docker implemented in around 100 lines of bash. Docker implemented in 100 lines of bash.
* [Prerequisites](#prerequisites) * [Prerequisites](#prerequisites)
* [Example Usage](#example-usage) * [Example Usage](#example-usage)
@ -12,56 +12,51 @@ Docker implemented in around 100 lines of bash.
The following packages are needed to run bocker. The following packages are needed to run bocker.
* btrfs-progs * btrfs-progs
* curl
* iproute2 * iproute2
* iptables * iptables
* libcgroup-tools
* util-linux >= 2.25.2 * util-linux >= 2.25.2
* coreutils >= 7.5
Because most distributions do not ship a new enough version of util-linux you will probably need to grab the sources from [here](https://www.kernel.org/pub/linux/utils/util-linux/v2.25/) and compile it yourself. Because most distributions do not ship a new enough version of util-linux you will probably need grab the sources from [here](https://www.kernel.org/pub/linux/utils/util-linux/v2.25/) and compile it yourself.
Additionally your system will need to be configured with the following: Additionally your system will need to be configured with the following.
* A btrfs filesystem mounted under `/var/bocker` * A btrfs filesystem mounted under `/var/bocker`
* A network bridge called `bridge0` and an IP of 10.0.0.1/24 * A network bridge called `bridge0` and an IP of 10.0.0.1/24
* IP forwarding enabled in `/proc/sys/net/ipv4/ip_forward` * IP forwarding enabled in `/proc/sys/net/ipv4/ip_forward`
* A firewall routing traffic from `bridge0` to a physical interface. * A firewall routing traffic from `bridge0` to a physical interface.
* A `base-image` which contains the filesystem to seed your container with.
For ease of use a Vagrantfile is included which will build the needed environment. 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**. 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 wont trash your system**.
## Example Usage ## Example Usage
``` ```
$ bocker pull centos 7 $ bocker init base-image/
######################################################################## 100.0% Created: img_84632
######################################################################## 100.0%
######################################################################## 100.0%
Created: img_42150
$ bocker images $ bocker images
IMAGE_ID SOURCE IMAGE_ID
img_42150 centos:7 img_84632
$ bocker run img_42150 cat /etc/centos-release $ bocker run img_84632 uname -sro
CentOS Linux release 7.1.1503 (Core) Linux 3.10.0-123.20.1.el7.x86_64 GNU/Linux
$ bocker ps $ bocker ps
CONTAINER_ID COMMAND CONTAINER_ID COMMAND
ps_42045 cat /etc/centos-release ps_12277 uname -sro
$ bocker logs ps_42045 $ bocker logs ps_12277
CentOS Linux release 7.1.1503 (Core) Linux 3.10.0-123.20.1.el7.x86_64 GNU/Linux
$ bocker rm ps_42045 $ bocker rm ps_12277
Removed: ps_42045 Removed: ps_12277
$ bocker run img_42150 which wget $ bocker run img_84632 which wget
which: no wget in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin) which: no wget in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
$ bocker run img_42150 yum install -y wget $ bocker run img_84632 yum install -y wget
Installing : wget-1.14-10.el7_0.1.x86_64 1/1 Installing : wget-1.14-10.el7_0.1.x86_64 1/1
Verifying : 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 Installed : wget.x86_64 0:1.14-10.el7_0.1
@ -69,62 +64,47 @@ Complete!
$ bocker ps $ bocker ps
CONTAINER_ID COMMAND CONTAINER_ID COMMAND
ps_42018 yum install -y wget ps_14099 which wget
ps_42182 which wget ps_43377 yum install -y wget
$ bocker commit ps_42018 img_42150 $bocker commit ps_43377 img_84632
Removed: img_42150 Removed: img_84632
Created: img_42150 Created: img_84632
$ bocker run img_42150 which wget $ bocker run img_84632 which wget
/usr/bin/wget /usr/bin/wget
$ bocker run img_42150 cat /proc/1/cgroup $ bocker rm ps_14099
... Removed: ps_14099
4:memory:/ps_42152
3:cpuacct,cpu:/ps_42152
$ cat /sys/fs/cgroup/cpu/ps_42152/cpu.shares $ bocker rm ps_43377
512 Removed: ps_43377
$ cat /sys/fs/cgroup/memory/ps_42152/memory.limit_in_bytes $ bocker rm ps_95942
512000000 Removed: ps_95942
$ BOCKER_CPU_SHARE=1024 \ $ bocker rm img_84632
BOCKER_MEM_LIMIT=1024 \ Removed: img_84632
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 ## Functionality: Currently Implemented
* `docker build` * `docker build`
* `docker pull`
* `docker images` * `docker images`
* `docker ps` * `docker ps`
* `docker run` * `docker run`
* `docker exec`
* `docker logs` * `docker logs`
* `docker commit` * `docker commit`
* `docker rm` / `docker rmi` * `docker rm` / `docker rmi`
* Networking * Networking
* Quota Support / CGroups
`bocker init` provides a very limited implementation of `docker build` `bocker init` provides a very limited implemetation of `docker build`
## Functionality: Not Yet Implemented ## Functionality: Not Yet Implemented
* Data Volume Containers
* Data Volumes
* Port Forwarding * Port Forwarding
* Data Volumes
* Data Volume Containers
## License ## License

2
Vagrantfile vendored
View File

@ -1,7 +1,7 @@
$script = <<SCRIPT $script = <<SCRIPT
( (
rpm -i https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm rpm -i https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
yum install -y -q autoconf automake btrfs-progs docker gettext-devel git libcgroup-tools libtool python-pip yum install -y -q autoconf automake btrfs-progs docker gettext-devel git libtool python-pip
fallocate -l 10G ~/btrfs.img fallocate -l 10G ~/btrfs.img
mkdir /var/bocker mkdir /var/bocker

187
bocker
View File

@ -1,119 +1,96 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o errexit -o nounset -o pipefail; shopt -s nullglob set -o errexit -o nounset -o pipefail; shopt -s nullglob
btrfs_path='/var/bocker' && cgroups='cpu,cpuacct,memory'; btrfs_path='/var/bocker';
[[ $# -gt 0 ]] && while [ "${1:0:2}" == '--' ]; do OPTION=${1:2}; [[ $OPTION =~ = ]] && declare "BOCKER_${OPTION/=*/}=${OPTION/*=/}" || declare "BOCKER_${OPTION}=x"; shift; done function CHECK() {
[[ "$1" == 'img' ]] && TYPE='image'
function bocker_check() { [[ "$1" == 'ps' ]] && TYPE='container'
btrfs subvolume list "$btrfs_path" | grep -qw "$1" && echo 0 || echo 1 [[ "$1" == '' ]] && TYPE='container or image'
} if [[ "$2" == "$1"* ]]; then
if btrfs subvolume list "$btrfs_path" | grep -qw "$2"; then
function bocker_init() { #HELP Create an image from a directory:\nBOCKER init <directory> return 0
uuid="img_$(shuf -i 42002-42254 -n 1)"
if [[ -d "$1" ]]; then
[[ "$(bocker_check "$uuid")" == 0 ]] && bocker_run "$@"
btrfs subvolume create "$btrfs_path/$uuid" > /dev/null
cp -rf --reflink=auto "$1"/* "$btrfs_path/$uuid" > /dev/null
[[ ! -f "$btrfs_path/$uuid"/img.source ]] && echo "$1" > "$btrfs_path/$uuid"/img.source
echo "Created: $uuid"
else
echo "No directory named '$1' exists"
fi fi
fi
echo "No $TYPE named '$2' exists" && exit 1
} }
function INIT() {
function bocker_pull() { #HELP Pull an image from Docker Hub:\nBOCKER pull <name> <tag> if [[ -d "$1" ]]; then
token="$(curl -sL -o /dev/null -D- -H 'X-Docker-Token: true' "https://index.docker.io/v1/repositories/$1/images" | tr -d '\r' | awk -F ': *' '$1 == "X-Docker-Token" { print $2 }')" uuid="img_$(shuf -i 10000-99999 -n 1)"
registry='https://registry-1.docker.io/v1' btrfs subvolume create "$btrfs_path/$uuid" > /dev/null
id="$(curl -sL -H "Authorization: Token $token" "$registry/repositories/$1/tags/$2" | sed 's/"//g')" cp -rf --reflink=auto "$1"/* "$btrfs_path/$uuid" > /dev/null
[[ "${#id}" -ne 64 ]] && echo "No image named '$1:$2' exists" && exit 1 echo "Created: $uuid"
ancestry="$(curl -sL -H "Authorization: Token $token" "$registry/images/$id/ancestry")" else
IFS=',' && ancestry=(${ancestry//[\[\] \"]/}) && IFS=' \n\t'; tmp_uuid="$(uuidgen)" && mkdir /tmp/"$tmp_uuid" echo "No directory named '$1' exists"
for id in "${ancestry[@]}"; do fi
curl -#L -H "Authorization: Token $token" "$registry/images/$id/layer" -o /tmp/"$tmp_uuid"/layer.tar
tar xf /tmp/"$tmp_uuid"/layer.tar -C /tmp/"$tmp_uuid" && rm /tmp/"$tmp_uuid"/layer.tar
done
echo "$1:$2" > /tmp/"$tmp_uuid"/img.source
bocker_init /tmp/"$tmp_uuid" && rm -rf /tmp/"$tmp_uuid"
} }
function RM() {
function bocker_rm() { #HELP Delete an image or container:\nBOCKER rm <image_id or container_id> CHECK '' "$1"
[[ "$(bocker_check "$1")" == 1 ]] && echo "No container named '$1' exists" && exit 1 btrfs subvolume delete "$btrfs_path/$1" > /dev/null
btrfs subvolume delete "$btrfs_path/$1" > /dev/null echo "Removed: $1"
cgdelete -g "$cgroups:/$1" &> /dev/null || true
echo "Removed: $1"
} }
function IMAGES() {
function bocker_images() { #HELP List images:\nBOCKER images echo -e "IMAGE_ID"
echo -e "IMAGE_ID\t\tSOURCE" for img in "$btrfs_path"/img_*; do
for img in "$btrfs_path"/img_*; do basename "$img"
img=$(basename "$img") done
echo -e "$img\t\t$(cat "$btrfs_path/$img/img.source")"
done
} }
function PS() {
function bocker_ps() { #HELP List containers:\nBOCKER ps echo -e "CONTAINER_ID\t\tCOMMAND"
echo -e "CONTAINER_ID\t\tCOMMAND" for ps in "$btrfs_path"/ps_*; do
for ps in "$btrfs_path"/ps_*; do ps=$(basename "$ps")
ps=$(basename "$ps") echo -e "$ps\t\t$(cat "$btrfs_path/$ps/$ps.cmd")"
echo -e "$ps\t\t$(cat "$btrfs_path/$ps/$ps.cmd")" done
done
} }
function RUN() {
function bocker_run() { #HELP Create a container:\nBOCKER run <image_id> <command> CHECK 'img' "$1"
uuid="ps_$(shuf -i 42002-42254 -n 1)" uuid="ps_$(shuf -i 10000-99999 -n 1)"
[[ "$(bocker_check "$1")" == 1 ]] && echo "No image named '$1' exists" && exit 1 ip link add dev veth0_"$uuid" type veth peer name veth1_"$uuid"
[[ "$(bocker_check "$uuid")" == 0 ]] && echo "UUID conflict, retrying..." && bocker_run "$@" && return ip link set dev veth0_"$uuid" up
cmd="${@:2}" && ip="$(echo "${uuid: -3}" | sed 's/0//g')" && mac="${uuid: -3:1}:${uuid: -2}" ip link set veth0_"$uuid" master bridge0
ip link add dev veth0_"$uuid" type veth peer name veth1_"$uuid" ip netns add netns_"$uuid"
ip link set dev veth0_"$uuid" up ip link set veth1_"$uuid" netns netns_"$uuid"
ip link set veth0_"$uuid" master bridge0 ip netns exec netns_"$uuid" ip link set dev lo up
ip netns add netns_"$uuid" ip netns exec netns_"$uuid" ip addr add 10.0.0.2/24 dev veth1_"$uuid"
ip link set veth1_"$uuid" netns netns_"$uuid" ip netns exec netns_"$uuid" ip link set dev veth1_"$uuid" up
ip netns exec netns_"$uuid" ip link set dev lo up ip netns exec netns_"$uuid" ip route add default via 10.0.0.1
ip netns exec netns_"$uuid" ip link set veth1_"$uuid" address 02:42:ac:11:00"$mac" btrfs subvolume snapshot "$btrfs_path/$1" "$btrfs_path/$uuid" > /dev/null
ip netns exec netns_"$uuid" ip addr add 10.0.0."$ip"/24 dev veth1_"$uuid" echo 'nameserver 8.8.8.8' > "$btrfs_path/$uuid"/etc/resolv.conf
ip netns exec netns_"$uuid" ip link set dev veth1_"$uuid" up echo "$2" > "$btrfs_path/$uuid/$uuid.cmd"
ip netns exec netns_"$uuid" ip route add default via 10.0.0.1 ip netns exec netns_"$uuid" "unshare" -fp --mount-proc "chroot" \
btrfs subvolume snapshot "$btrfs_path/$1" "$btrfs_path/$uuid" > /dev/null "$btrfs_path/$uuid" /bin/sh -c "/bin/mount -t proc proc /proc && $2" \
echo 'nameserver 8.8.8.8' > "$btrfs_path/$uuid"/etc/resolv.conf 2>&1 | tee "$btrfs_path/$uuid/$uuid.log" || true
echo "$cmd" > "$btrfs_path/$uuid/$uuid.cmd" ip link del dev veth0_"$uuid"
cgcreate -g "$cgroups:/$uuid" ip netns del netns_"$uuid"
: "${BOCKER_CPU_SHARE:=512}" && cgset -r cpu.shares="$BOCKER_CPU_SHARE" "$uuid"
: "${BOCKER_MEM_LIMIT:=512}" && cgset -r memory.limit_in_bytes="$((BOCKER_MEM_LIMIT * 1000000))" "$uuid"
cgexec -g "$cgroups:$uuid" \
ip netns exec netns_"$uuid" \
unshare -fmuip --mount-proc \
chroot "$btrfs_path/$uuid" \
/bin/sh -c "/bin/mount -t proc proc /proc && $cmd" \
2>&1 | tee "$btrfs_path/$uuid/$uuid.log" || true
ip link del dev veth0_"$uuid"
ip netns del netns_"$uuid"
} }
function LOGS() {
function bocker_exec() { #HELP Execute a command in a running container:\nBOCKER exec <container_id> <command> CHECK 'ps' "$1"
[[ "$(bocker_check "$1")" == 1 ]] && echo "No container named '$1' exists" && exit 1 cat "$btrfs_path/$1/$1.log"
cid="$(ps o ppid,pid | grep "^$(ps o pid,cmd | grep -E "^\ *[0-9]+ unshare.*$1" | awk '{print $1}')" | awk '{print $2}')"
[[ ! "$cid" =~ ^\ *[0-9]+$ ]] && echo "Container '$1' exists but is not running" && exit 1
nsenter -t "$cid" -m -u -i -n -p chroot "$btrfs_path/$1" "${@:2}"
} }
function COMMIT() {
function bocker_logs() { #HELP View logs from a container:\nBOCKER logs <container_id> CHECK 'ps' "$1" && CHECK 'img' "$2" && RM "$2"
[[ "$(bocker_check "$1")" == 1 ]] && echo "No container named '$1' exists" && exit 1 btrfs subvolume snapshot "$btrfs_path/$1" "$btrfs_path/$2" > /dev/null
cat "$btrfs_path/$1/$1.log" echo "Created: $2"
} }
function HELP() {
function bocker_commit() { #HELP Commit a container to an image:\nBOCKER commit <container_id> <image_id> echo -e "Create an image: \n\t./bocker init <image_directory>\n"
[[ "$(bocker_check "$1")" == 1 ]] && echo "No container named '$1' exists" && exit 1 echo -e "List images: \n\t./bocker images\n"
[[ "$(bocker_check "$2")" == 1 ]] && echo "No image named '$2' exists" && exit 1 echo -e "Create a container: \n\t./bocker run <image_id> <command>\n"
bocker_rm "$2" && btrfs subvolume snapshot "$btrfs_path/$1" "$btrfs_path/$2" > /dev/null echo -e "List containers: \n\t./bocker ps\n"
echo "Created: $2" echo -e "View logs from a container: \n\t./bocker logs <container_id>\n"
echo -e "Delete an image or container: \n\t./bocker rm <image_or_container_id>"
exit 0
} }
[[ -z "${1-}" ]] && HELP
function bocker_help() { #HELP Display this message:\nBOCKER help
sed -n "s/^.*#HELP\\s//p;" < "$1" | sed "s/\\\\n/\n\t/g;s/$/\n/;s!BOCKER!${1/!/\\!}!g"
}
[[ -z "${1-}" ]] && bocker_help "$0"
case $1 in case $1 in
pull|init|rm|images|ps|run|exec|logs|commit) bocker_"$1" "${@:2}" ;; init) INIT "$2" ;;
*) bocker_help "$0" ;; rm) RM "$2" ;;
images) IMAGES ;;
ps) PS ;;
run)
IMAGE="$2"
shift && shift
RUN "$IMAGE" "$*"
;;
logs) LOGS "$2" ;;
commit) COMMIT "$2" "$3" ;;
*) HELP ;;
esac esac

15
test
View File

@ -1,15 +0,0 @@
#!/usr/bin/env bash
exit_code=0
for t in tests/test_*; do
bash tests/teardown > /dev/null 2>&1
bash "$t" > /dev/null 2>&1
if [[ $? == 0 ]]; then
echo -e "\e[1;32mPASSED\e[0m : $t"
else
echo -e "\e[1;31mFAILED\e[0m : $t"
exit_code=1
fi
bash tests/teardown > /dev/null 2>&1
done
exit "$exit_code"

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
for img in $(./bocker images | grep 'img' | awk '{print $1}'); do
./bocker rm "$img"
done
for ps in $(./bocker ps | grep 'ps' | awk '{print $1}'); do
./bocker rm "$ps"
done

View File

@ -1,21 +0,0 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
img="$(./bocker init ~/base-image | awk '{print $2}')"
./bocker images | grep -qw "$img"
[[ "$?" == 0 ]]
./bocker run "$img" which wget
ps="$(./bocker ps | grep 'which wget' | awk '{print $1}')"
logs="$(./bocker logs "$ps")"
./bocker rm "$ps"
[[ "$logs" == "which: no wget in"* ]]
./bocker run "$img" yum install -y wget
ps="$(./bocker ps | grep 'yum install -y wget' | awk '{print $1}')"
./bocker commit "$ps" "$img"
./bocker run "$img" which wget
ps="$(./bocker ps | grep 'which wget' | awk '{print $1}')"
logs="$(./bocker logs "$ps")"
[[ "$logs" == '/usr/bin/wget' ]]

View File

@ -1,23 +0,0 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
img="$(./bocker init ~/base-image | awk '{print $2}')"
./bocker images | grep -qw "$img"
[[ "$?" == 0 ]]
# ▼ ▼ ▼ Race condition waiting to happen ▼ ▼ ▼
./bocker run "$img" "sleep 5 && ps aux" &
sleep 2
ps="$(./bocker ps | grep 'sleep 5' | awk '{print $1}')"
exec="$(./bocker exec "$ps" ps aux | wc -l)"
[[ "$exec" == "4" ]]
sleep 3
# ▲ ▲ ▲ Race condition waiting to happen ▲ ▲ ▲
./bocker run "$img" ps aux
ps="$(./bocker ps | grep 'ps aux' | awk '{print $1}')"
exec="$(./bocker exec "$ps" ps aux)" || true
[[ "$exec" == "Container '$ps' exists but is not running" ]]
exec="$(./bocker exec foo ps aux)" || true
[[ "$exec" == "No container named 'foo' exists" ]]

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
[[ "$(./bocker images | head -n 1)" == 'IMAGE_ID SOURCE' ]]

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
[[ "$(./bocker init ~/base-image)" == 'Created: img_'* ]]

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
[[ "$(./bocker ps | head -n 1)" == 'CONTAINER_ID COMMAND' ]]

View File

@ -1,16 +0,0 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
centos_img="$(./bocker pull centos 7 2> /dev/null | awk '{print $2}')"
./bocker run "$centos_img" cat /etc/redhat-release
ps="$(./bocker ps | grep 'cat /etc/redhat-release' | awk '{print $1}')"
logs="$(./bocker logs "$ps")"
./bocker rm "$ps"
[[ "$logs" == "CentOS Linux release 7"* ]]
ubuntu_img="$(./bocker pull ubuntu 14.04 2> /dev/null | awk '{print $2}')"
./bocker run "$ubuntu_img" tail -n1 /etc/lsb-release
ps="$(./bocker ps | grep 'tail -n1 /etc/lsb-release' | awk '{print $1}')"
logs="$(./bocker logs "$ps")"
./bocker rm "$ps"
[[ "$logs" == *"Ubuntu 14.04"* ]]

View File

@ -1,16 +0,0 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
img="$(./bocker init ~/base-image | awk '{print $2}')"
cmd="echo $RANDOM"
./bocker run "$img" "$cmd"
ps="$(./bocker ps | grep "$cmd" | awk '{print $1}')"
[[ "$(./bocker images | grep -c "$img")" == 1 ]]
[[ "$(./bocker ps | grep -c "$cmd")" == 1 ]]
./bocker rm "$img"
./bocker rm "$ps"
[[ "$(./bocker images | grep -c "$img")" == 0 ]]
[[ "$(./bocker ps | grep -c "$cmd")" == 0 ]]

View File

@ -1,24 +0,0 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
function bocker_run_test() {
./bocker run "$1" "$2" > /dev/null
ps="$(./bocker ps | grep "$2" | awk '{print $1}')"
logs="$(./bocker logs "$ps")"
if [[ "$logs" == *"$3"* ]]; then
echo 0
else
echo 1
fi
}
img="$(./bocker init ~/base-image | awk '{print $2}')"
./bocker images | grep -qw "$img"
[[ "$?" == 0 ]]
[[ "$(bocker_run_test "$img" 'echo foo' 'foo')" == 0 ]]
[[ "$(bocker_run_test "$img" 'uname' 'Linux')" == 0 ]]
[[ "$(bocker_run_test "$img" 'cat /proc/self/stat' '3 (cat)')" == 0 ]]
[[ "$(bocker_run_test "$img" 'ip addr' 'veth1_ps_')" == 0 ]]
[[ "$(bocker_run_test "$img" 'ping -c 1 8.8.8.8' '0% packet loss')" == 0 ]]
[[ "$(bocker_run_test "$img" 'ping -c 1 google.com' '0% packet loss')" == 0 ]]