离线安装
如果是离线安装的docker,可以自己准备一份containerd.service用于管理containerd启停。
containerd config default > /etc/containerd/config.toml
sudo vim /etc/systemd/system/containerd.service
[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target
[Service]
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/bin/containerd
Type=notify
Delegate=yes
KillMode=process
Restart=always
RestartSec=5
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
LimitNOFILE=1048576
# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this version.
TasksMax=infinity
OOMScoreAdjust=-999
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start containerd
sudo systemctl enable containerd
nerdctl
containerd自带的ctl命令与docker命令不一样,使用不习惯的用户可以考虑安装nerdctl
。这个工具命令风格和docker一致。
wget https://github.com/containerd/nerdctl/releases/download/v2.0.1/nerdctl-2.0.1-linux-amd64.tar.gz
sudo tar -C /usr/local/bin -xzf nerdctl-2.0.1-linux-amd64.tar.gz
nerdctl version
安装CNI插件
下载页下载最新版本
wget https://github.com/containernetworking/plugins/releases/download/v1.6.1/cni-plugins-linux-amd64-v1.6.1.tgz
sudo mkdir -p /opt/cni/bin
sudo tar -xzf cni-plugins-linux-amd64-v1.6.1.tgz -C /opt/cni/bin
ls /opt/cni/bin
检查containerd配置,确保CNI配置正确
[plugins."io.containerd.grpc.v1.cri".cni]
bin_dir = "/opt/cni/bin"
conf_dir = "/etc/cni/net.d"
然后重启sudo systemctl restart containerd
.
使用nerdctl network create bridge
创建一个新的默认 bridge 网络.
nerdctl network ls