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/

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.创建 /usr/lib/systemd/system/docker.service

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

复制以下内容

[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

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

nano /usr/lib/systemd/system/docker.socket
[Unit]
Description=Docker Socket for the API

[Socket]
ListenStream=/var/run/docker.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker

[Install]
WantedBy=sockets.target

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

nano /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=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. 赋权限
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. 创建docker组
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker 

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

systemctl daemon-reload
systemctl start docker
systemctl enable docker

7.查看状态

systemctl status docker

返回结果

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

到此安装完成

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值