I'm trying to find out how docker implements filesystem level isolation, I've done some reading about how container isolate filesystem like https://www.oreilly.com/library/view/container-security/9781492056690/ch04.html, https://www.youtube.com/watch?v=8fi7uSYlOdc, both of them tell me that container typically use chroot to achieve filesystem level isolation. When I try to use the strace tool to detect the syscalls used by docker run, I don't find the chroot syscall, this confuses me.
The entire strace command I use is strace -f -o result.txt docker run --rm -it ubuntu bash, I find syscall used by docker run in result.txt, I search the whole file but cann't find chroot syscall
My questions are:
- whether this problem is caused by
strace,stracecan't trace syscall in container sochrootis omitted, if it is, what else methods can I use to detectchrootsyscall? - If
chrootreally isn't being used indocker run, What mechanism does docker use to achieve filesystem isolation?
Docker is a client server application. All docker cli does is it sends requests to docker deamon. Docker deamon does all the work. You have to stop docker deamon and run dockerd inside strace and then you will see
chrootandpivot_rootsystem calls.Here I run a docker-in-docker for testing, because I do not want to touch my host docker deamon, do run a strace dockerd command and then run a alpine image. I filter with grep because I am lazy. You can see
pivot_root("/var/lib/docker/overlay2..."syscall made by dockerd.