Install Kata Containers on CentOS
yum install wget -y
sudo -E dnf install -y centos-release-advanced-virtualization
sudo -E dnf module disable -y virt:rhel
source /etc/os-release
echo "[kata-containers]
name=Kata Containers
baseurl=http://mirrors.aliyun.com/\$contentdir/\$releasever/virt/\$basearch/kata-containers
enabled=1
gpgcheck=1
skip_if_unavailable=1
" > /etc/yum.repos.d/kata-containers.repo
sudo -E dnf install -y kata-containers
yum install yum-utils -y
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum -y install docker-ce
mkdir -p /etc/systemd/system/docker.service.d/
cat <<EOF | sudo tee /etc/systemd/system/docker.service.d/kata-containers.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -D --add-runtime kata-runtime=/usr/bin/kata-runtime --default-runtime=kata-runtime
EOF
sudo mkdir -p /etc/docker
将以下定义添加到/etc/docker/daemon.json:
{
"default-runtime": "kata-runtime",
"runtimes": {
"kata-runtime": {
"path": "/usr/bin/kata-runtime"
}
}
}
使用以下命令重新启动Docker systemd服务:
sudo systemctl daemon-reload
sudo systemctl restart docker
测试
运行Kata Containers
sudo docker run busybox uname -a
此时命令显示了在容器内运行的内核版本的详细信息,这应与主机的内核版本不同。