• Debian10离线安装docker-20.10.13


    以下操作都是使用root用户

    下载、上传、解压和移动到执行目录

    1.到官方下载页面,找到对应硬件平台的docker-20.10.13.tgz 下载,并上传到debian系统上。我选择的是x86_64的。
    2.解压并移动到执行目录上

    tar xzvf docker-20.10.13.tgz
    sudo cp docker/* /usr/bin/
    
    • 1
    • 2

    3.创建deaemon.json配置文件
    无法联网,需要docker连接内网镜像库
    新建 /etc/docker文件夹
    新建 /etc/docker/daemon.json 文件,并添加内容

    {  
      "insecure-registries": [
        "192.168.1.230:8000"   
      ],
      "log-driver":"json-file",
      "log-opts": {"max-size":"2g", "max-file":"3"}
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    自启动配置

    1.创建 /usr/lib/systemd/system/docker.service

    nano /usr/lib/systemd/system/docker.service
    
    • 1

    复制以下内容

    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    After=network-online.target 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
    TimeoutSec=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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47

    2.创建/usr/lib/systemd/system/docker.socket

    nano /usr/lib/systemd/system/docker.socket
    
    • 1
    [Unit]
    Description=Docker Socket for the API
    
    [Socket]
    ListenStream=/var/run/docker.sock
    SocketMode=0660
    SocketUser=root
    SocketGroup=docker
    
    [Install]
    WantedBy=sockets.target
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    3.创建 /usr/lib/systemd/system/containerd.service

    nano /usr/lib/systemd/system/containerd.service
    
    • 1
    # 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=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
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    1. 赋权限
    chmod +x /usr/lib/systemd/system/docker.socket
    chmod +x /usr/lib/systemd/system/docker.service
    chmod +x /usr/lib/systemd/system/containerd.service
    
    • 1
    • 2
    • 3
    1. 创建docker组
    sudo groupadd docker
    sudo usermod -aG docker $USER
    newgrp docker 
    
    • 1
    • 2
    • 3

    最好重启一下系统
    6. 启动docker,并开启开机自启动

    systemctl daemon-reload
    systemctl start docker
    systemctl enable docker
    
    
    • 1
    • 2
    • 3
    • 4

    7.查看状态

    systemctl status docker
    
    • 1

    返回结果

    docker.service - Docker Application Container Engine
       Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
       Active: active (running) since Tue 2022-08-09 12:02:52 CST; 1h 19min ago
         Docs: https://docs.docker.com
     Main PID: 899 (dockerd)
        Tasks: 8
       Memory: 81.8M
       CGroup: /system.slice/docker.service
               └─899 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    到此安装完成

  • 相关阅读:
    js实现查找两个相同字符串之间的最长子字符串长度
    有哪些好用的实时网络流量监控软件
    背就有效!2024下《系统架构设计师》50个高频考点汇总
    外贸公司保密协议 (2)
    学会这8点小技巧,让你公众号永不断更!
    栈的压入、弹出序列
    分布式锁的实现原理
    【Spring】——11、了解BeanPostProcessor后置处理器
    [数据集][目标检测]老鼠检测数据集VOC+YOLO格式4107张1类别
    日常学习记录随笔-seata
  • 原文地址:https://blog.csdn.net/lms99251/article/details/126245436