Mini-docker is the mini version of docker, which can realize functions similar to docker, such as running/deleting containers, building images, configuring container networks, etc. It is built using Linux Namespace
and Cgroup
technology.
If you want to try mini-docker, you need to have go
and make
tools. Then execute the following command.
$ go mod tidy
$ make
When mini-docker is running, related technologies such as Linux Namespace
need to be used, and root permission
is required. mini-docker mainly relies on the /root/mini-docker
directory, it will look for the image in this directory, and the information generated by the container running process will also be saved in this directory, so before using mini-docker, you need to create the above directory, the corresponding directory structure is as follows.
/root/mini-docker
├── containers # container work directory
└── images # container images
The next container operation uses the alpine-linux
image(Of course, you can also use container images exported by docker). If you don't have this image, you will download.
wget https://mirror.nju.edu.cn/alpine/latest-stable/releases/x86_64/alpine-minirootfs-3.20.0-x86_64.tar.gz -O /root/mini-docker/images/alpine.tar.gz
Now you can enjoy using mini-docker. The following uses running containers as an example. You can view more operations of mini-docker by using ./bin/mini-docker -h
.
$ # the following command runs the alpine container and runs /bin/sh for interactive processing.
$ sudo ./bin/mini-docker run --ti --name alpine alpine sh