root@ubuntu:/mnt/kata# ls bin boot dev etc home lib lost+found media mnt opt proc root run sbin srv sys tmp usr var root@ubuntu:/mnt/kata# find . -name libcontainer root@ubuntu:/mnt/kata# find . -name libcontainer* root@ubuntu:/mnt/kata# find . -name kata-agent ./usr/bin/kata-agent root@ubuntu:/mnt/kata# nm -C ./usr/bin/kata-agent | grep libcontainer 00000000013290c0 b github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer/apparmor.ErrApparmorNotEnabled 0000000000911f90 t github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer/apparmor.init 0000000001349509 b github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer/apparmor.initdone. 00000000009153a0 t github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer.awaitFifoOpen 0000000000933070 t github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer.awaitFifoOpen.func1 000000000092e6e0 t github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer.bindMountDeviceNode 0000000000927260 t github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer.(*Boolmsg).Len 0000000000926fc0 t github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer.(*Boolmsg).Serialize 0000000000926fa0 t github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer.(*Bytemsg).Len 0000000000926d30 t github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer.(*Bytemsg).Serialize 0000000001327fe8 b github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer.capabilityMap 0000000000922940 t github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer.Cgroupfs 00000000009228c0 t github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer.cgroupfs2 0000000000933140 t github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer.cgroupfs2.func1 00000000009331d0 t github.com/kata-containers/agent/vendor/github.com/opencontainers/runc/libcontainer.Cgroupfs.func1
runC 实现
runC
可以启动并管理符合OCI标准的容器。简单地说,runC
需要利用OCI bundle
创建一个独立的运行环境,并执行指定的程序。在Linux平台上,这个环境就是指各种类型的Namespace
以及Capability
等等配置
代码结构
runC
由Go语言实现,当前(2018.12)最新版本是v1.0.0-rc6,代码的结构可分为两大块,一是根目录下的go文件,对应各个runC
命令,二是负责创建/启动/管理容器的libcontainer
,可以说runC
的本质都在libcontainer