Dockerはruncを利用してLinuxカーネル機能でコンテナを作成する。
runcではホストのカーネルを共有して利用するため、1つのコンテナに問題があれば他にも影響する可能性が高くなる。
Kata Containersはハイパーバイザーを利用してコンテナ毎にカーネルを動作させる。
環境について
# cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS" # docker --version Docker version 20.10.6, build 370c289
Kata Containersのインストール
2021年5月20日時点の最新バージョンは2.1.0であるが、インストールの容易さや管理しやすさからsnapdでインストールしてみた。
# apt install snapd # snap install kata-containers error: This revision of snap "kata-containers" was published using classic confinement and thus may perform arbitrary system changes outside of the security sandbox that snaps are usually confined to, which may put your system at risk. If you understand and want to proceed repeat the command including --classic. # snap install kata-containers --classic # snap list Name Version Rev Tracking Publisher Notes core20 20210429 1026 latest/stable canonical✓ base kata-containers 1.12.1 716 latest/stable katacontainers✓ classic snapd 2.50 11841 latest/stable canonical✓ snapd
ランタイムとしてKata Containersを利用してみようとしたがエラーだった
公式のインストールページにもある通り、AWSであればベアメタルインスタンスでないと動作しないなど制約は多く、手持ちの仮想環境では動作しなかった。(さくらのVPS)
# vi /etc/docker/daemon.json { "default-address-pools":[ {"base":"192.168.0.0/16","size":24} ], "runtimes":{ "kata": { "path": "/snap/bin/kata-containers.runtime" } } } # systemctl restart docker # docker run --runtime=kata centos uname -a docker: Error response from daemon: OCI runtime create failed: failed to launch qemu: exit status 1, error messages from qemu log: qemu-system-x86_64: -m 2048M,slots=10,maxmem=2009M: invalid value of -m option maxmem: maximum memory size (0x7d900000) must be at least the initial memory size (0x80000000): unknown.