当前位置: 首页>后端>正文

麒麟V10安装docker

安装条件

64位的操作系统

# uname -p
aarch64

Linux 内核版本 ≥ 3.10

# uname -r
4.19.90-17.ky10.aarch64

iptables 版本 ≥ 1.4

# iptables --version
iptables v1.8.1 (legacy)

下载docker

  1. 选择并下载 docker 二进制包文件
    官网下载地址:Index of linux/static/stable/aarch64/
    e.g. wget https://download.docker.com/linux/static/stable/aarch64/docker-20.10.7.tgz
  2. 解压下载好的压缩包
tar -zxvf docker-20.10.7.tgz
  1. 移动解压出来的二进制文件到 /usr/bin 目录中
mv docker/* /usr/bin/
  1. 测试启动
# dockerd
...
INFO[2024-03-08T10:38:55.700076543+08:00] Daemon has completed initialization
INFO[2024-03-08T10:38:55.722411381+08:00] API listen on /var/run/docker.sock

添加 systemd

  1. 添加 docker 的 systemd 服务脚本至 /usr/lib/systemd/system/
    脚本参考自 https://github.com/docker/docker-ce
    vim /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket containerd.service
 
[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 -H fd:// --containerd=/run/containerd/containerd.sock
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.
LimitNOFILE=infinity
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
  1. 根据 docker.service 中 Unit.After 需求添加 docker.socket 脚本至 /usr/lib/systemd/system/
    脚本参考自 https://github.com/docker/docker-ce
    vim /usr/lib/systemd/system/docker.socket
[Unit]
Description=Docker Socket for the API
 
[Socket]
# If /var/run is not implemented as a symlink to /run, you may need to
# specify ListenStream=/var/run/docker.sock instead.
ListenStream=/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
 
[Install]
WantedBy=sockets.target
  1. 根据 docker.service 中 Unit.After 需求添加 containerd.service 脚本至 /usr/lib/systemd/system/
    脚本参考自 https://github.com/containerd/containerd
    vim /usr/lib/systemd/system/containerd.service
# 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
 
[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=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
  1. 重载 systemd 配置文件
systemctl daemon-reload
  1. 创建 docker 组
groupadd docker
  1. 启动 docker 服务
systemctl start docker
systemctl enable docker
  1. 按需修改docker配置文件
    如更改默认位置在系统盘的容器数据根目录到数据盘
    vim /etc/docker/daemon.json
{
"data-root": "/data/docker"
}

重启docker服务生效

systemctl restart docker

参考:https://blog.csdn.net/zhangxiangweide/article/details/129439141


https://www.xamrdz.com/backend/3hv1937063.html

相关文章: