please read file how_to_play.txt to get a basic idea of how to play it.
This project is forked from https://github.com/xianlubird/mydocker which is a educational container engine for the book "write Docker from scratch". This book and this project provides guidences about how a build a simplified "Docker Engine".
Cheng Yu (s3341458, chengyu0316@gmail.com) modified it on each chapter branch and master branch {{ original branch }}-cheng for following reasons:
- original code has bugs and obsolete code due to library updates, so go build will fail
- original code has wrong imports
- original code of each chapter is not coherent. (eg, code of chapter 3.2 is actually ahead chapter 3.3)
- original code works on a old Ubuntu 14.04 linux kernel 3.13, I am using archlinux with much newer kernel
- original code is not ideal in terms of the code of itself (but at OK level)
Here are the differences compare to original code base
I fixed the issue that old code tried to imported the wrong package from github
Using syscall.Mount("", "/", "", syscall.MS_PRIVATE|syscall.MS_REC, "") makes the mount namespace works properly on my archlinux computer, systemd made "/" mounted as shared by default
Change the logs functions makes so I can find out why pivot was not working properly
It is almost the same as code-3.3-cheng due the issue of code of the book code-3.2 is exactly the same as code-4.1 add Cmd.Dir which gives a static image layer
Using overlayfs instead of aufs to implement container writable layer and base readble image layer
Using bind mount instead of aufs to implement docker volume
the code 4.4 actually implemented a mini version of "docker export" instead of "docker commit", so I just changed name of command and functions to "export"
exactly the same as original book I fix the issue that I miss remove the cgroup management in previouse commit
each docker container will have its own writeable layer based on their names fixed one import problem all container information will be stored in a local directory instead in /var/run/mydocker
all logs will be stored in current directory logs, each container will have a different log file based on its name
fix the issue where logs and info are not removed in delete workspace
almost the same as the original code, just fixed some tiny import issues
almost the same as the original code, just fixed some tiny import issues and function name issue
almost the same as the original code, add a clean command to remove all the containers related files for testing reason
almost the same as the original code, however since the implementation of this commit is too far away from the real docker so really did not get motivated.
In real docker world commit are implemented by copy files of container writable layer to image read-only layers with proper re-indexing. To implemented things to that really will take too much time.
almost the same as the original code, during the time test this stage I found issues in command line arg parsing(when environment and container name, it will mistakely take the later one as the image name), however such thing is not the main point of this project(understand docker working mechnism). SoI do not want spend extra time for this problem for now.
Almost the same as the original code, fix some bugs manage the code in a slightly more elegant way. All networks and ipam information will be put into networks folder in mydocker directory Due to a command args parsing bug, you need to specify image by --image and command by --command, this is different with how Docker looks in real world.
branch {{branch}}-cheng is my modifications on {{branch}} which makes it runable on my machine
sometimes the code in this book can not properly distinguish the whether the args are more mydocker or for the wrapped command. better use it in sudo ./mydocker -args argv "command command-args"