使用runc直接运行容器

组件containerd负责集群节点上容器的生命周期管理,并向上为docker daemon提供gRPC接口,containerd依靠runC去创建容器进程。而在容器启动之后,runC进程会退出。

可以使用runc直接创建容器,runc遵循OCI标准 https://www.opencontainers.org/,oci官网介绍如下:

Established in June 2015 by Docker and other leaders in the container industry, the OCI currently contains two specifications: the Runtime Specification (runtime-spec) and the Image Specification (image-spec). The Runtime Specification outlines how to run a “filesystem bundle” that is unpacked on disk. At a high-level an OCI implementation would download an OCI Image then unpack that image into an OCI Runtime filesystem bundle. At this point the OCI Runtime Bundle would be run by an OCI Runtime.

#创建测试目录
mkdir /mycontainer && cd /mycontainer

#创建测试容器文件系统目录
mkdir rootfs && cd rootfs

#根据容器tar包模拟生成Bundle
docker export {containerId}-o test-image.tar && tar -xf test-image.tar

#生成标准config.json
cd .. & runc spec

#runc使用rootfs和config.json创建并运行容器
runc run test 

  

上一篇:redis入门指南-附录A


下一篇:35-less 简明笔记