A couple of weeks ago, at the end of the docker hackday, I demo-ed dockerlite, a re-implementation of docker with posix shell scripts, and using BTRFS instead of AUFS for images and containers storage. Dockerlite proved itself to be an incredibly useful sandbox to test new concepts.
The first result is the implementation of basic docker operations using BTRFS instead of AUFS. Instead of using AUFS layers, it uses BTRFS subvolumes and snapshots. It is very efficient (since it doesn’t have to perform copy-up like AUFS) and down the road should be a more viable option than AUFS.
The code is available with a couple of caveats:
– BTRFS has no notion of “rw layer”, and has no easy way to list the differences between snapshots (i.e. between a container and its image); therefore, “docker diff” will not work as expected (it will list all the files of the container instead of listing only modifications) and the result of “docker commit” will be a full image (instead of a differential image). This will be improved in future versions. Meanwhile, you should be able do “docker pull” existing images without any problem.
– BTRFS IS VERY SENSITIVE TO LOW DISK SPACE CONDITIONS. So if you test that code, make sure that you have plenty of disk space. If disk space drops below 1 GB, stop, and enlarge your volume. Otherwise, the Go runtime might crash or freeze (even if there seems to be disk space available). I wasted almost 1 day to debug this issue (I was trying to understand why some tests would randomly fail…), I hope nobody else will hit it 🙂
The code is based on the 0.3.2 branch of docker. Feel free to give it a try (e.g. if you want to try docker on machines without AUFS support). If you want to see “docker diff” work correctly, and/or if you want to be able to “docker push” without uploading a full image, tell me, so I can know if there is interest for the feature 🙂
 “btrfs subvol find-new” only shows new and changed files; deleted files and metadata updates are not listed