LoongArch64 (loong64) 龙芯架构:从 GitHub 安装 github.com/kubernetes-loong64 编译的 containerd、docker 二进制

说明

暂未完成所有情况的测试

下方基于 AnolisOS 23.4 最小化安装 进行测试

源码

相关文档

下载二进制并安装

mkdir -p ~/docker
cd ~/docker

curl -LO https://github.com/kubernetes-loong64/containerd-loong64/releases/latest/download/containerd
curl -LO https://github.com/kubernetes-loong64/containerd-loong64/releases/latest/download/containerd-shim-runc-v2
curl -LO https://github.com/kubernetes-loong64/containerd-loong64/releases/latest/download/containerd-stress
curl -LO https://github.com/kubernetes-loong64/containerd-loong64/releases/latest/download/ctr

curl -LO https://github.com/kubernetes-loong64/runc-loong64/releases/latest/download/runc

curl -LO https://github.com/kubernetes-loong64/tini-loong64/releases/latest/download/docker-init-static

curl -LO https://github.com/kubernetes-loong64/cli-loong64/releases/latest/download/docker
curl -LO https://github.com/kubernetes-loong64/compose-loong64/releases/latest/download/docker-compose
curl -LO https://github.com/kubernetes-loong64/buildx-loong64/releases/latest/download/buildx

curl -LO https://github.com/kubernetes-loong64/moby-loong64/releases/latest/download/dockerd
curl -LO https://github.com/kubernetes-loong64/moby-loong64/releases/latest/download/docker-proxy

cp ~/docker/docker-init-static ~/docker/docker-init
cp ~/docker/buildx ~/docker/docker-buildx

chmod +x ~/docker/*
sudo cp ~/docker/* /usr/bin

mkdir -p /usr/libexec/docker/cli-plugins/
sudo cp ~/docker/docker-compose /usr/libexec/docker/cli-plugins/
sudo cp ~/docker/docker-buildx /usr/libexec/docker/cli-plugins/

创建 containerd 配置文件

sudo mkdir -p /etc/containerd
containerd config default > /etc/containerd/config.toml

创建 containerd Linux Service 服务

sudo tee /usr/lib/systemd/system/containerd.service <<EOF
# Copyright The containerd Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[Unit]
Description=containerd container runtime
Documentation=https://containerd.io
After=network.target local-fs.target dbus.service

[Service]
#uncomment to enable the experimental sbservice (sandboxed) version of containerd/cri integration
#Environment="ENABLE_CRI_SANDBOXES=sandboxed"
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=infinity
# 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

EOF

创建 docker Linux Service 服务

sudo tee /etc/systemd/system/docker.service <<EOF
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service time-set.target
Wants=network-online.target

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP \$MAINPID
TimeoutStartSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# 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

# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity

# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes

# kill only the docker process, not all processes in the cgroup
KillMode=process
OOMScoreAdjust=-500

[Install]
WantedBy=multi-user.target

EOF

启动服务

启动 containerd 服务

首先启动 containerd 服务,再启动 docker 服务

sudo systemctl daemon-reload
sudo systemctl enable containerd.service
sudo systemctl start containerd.service
[root@anolis docker]# sudo systemctl daemon-reload
[root@anolis docker]# sudo systemctl enable containerd.service
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /usr/lib/systemd/system/containerd.service.
[root@anolis docker]# sudo systemctl start containerd.service
[root@anolis docker]#

启动 docker 服务

首先启动 containerd 服务,再启动 docker 服务

sudo systemctl daemon-reload
sudo systemctl enable docker.service
sudo systemctl start docker.service
[root@anolis docker]# sudo systemctl daemon-reload
[root@anolis docker]# sudo systemctl enable docker.service
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
[root@anolis docker]# sudo systemctl start docker.service
[root@anolis docker]#

命令自动补充

执行完成,重新连接 Shell 即可

mkdir -p /usr/share/bash-completion/completions/
docker completion bash > /usr/share/bash-completion/completions/docker
mkdir -p /usr/share/fish/vendor_completions.d/
docker completion fish > /usr/share/fish/vendor_completions.d/docker.fish
mkdir -p /usr/share/zsh/site-functions/
docker completion zsh > /usr/share/zsh/site-functions/_docker