posts - 360,comments - 0,views - 19万

    适合场景

  1. 无法访问外网的服务器环境
  2. 内网没有Docker软件源
  3. 需要离线安装Docker
  4. 使用rpm或deb等Docker安装包出现依赖地狱的情况,而实施人员无力解决
  5. 支持Systemd服务配置
  6. 支持多种架构:aarch64/armel/armhf/ppc64le/s390x/x86_64

官网地址:https://download.docker.com/linux/static/stable/x86_64/

根据架构选择目录,本文以x86_64举例

复制代码
解压压缩包
tar -xvf docker-19.03.3-ce.tgz
将解压出的docker/bin目录下的可执行文件复制到/usr/bin
cp docker/* /usr/bin/
将docker注册为 Systemd 的 service
cat > /etc/systemd/system/docker.service <<EOF
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
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
# 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
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# 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
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOF
为 docker.service添加可执行权限

chmod +x /etc/systemd/system/docker.service
设置docker存储目录到大硬盘目录、设置私有镜像仓库地址(可选,注意替换目录位置与私有镜像仓库URL)
mkdir /etc/docker
mkdir /data1/docker #/data1是大硬盘目录
# 主要关注data-root的是最大硬盘目录存放docker容器系统相关的目录
# insecure-registries后边的值是私有镜像仓库地址,多个私有镜像仓库地址配置格式为["仓库1","仓库2"]
# exec-opts部分针对于部署k8s做的预配置,可以减少容器日志保存大小及配合kubelet使用systemd
cat > /etc/docker/daemon.json <<EOF
{
"insecure-registries":["10.2.41.191:5000"],
"data-root":"/data1/docker",
"exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "20m"
  },
  "storage-driver": "overlay2",
  "storage-opts": [
    "overlay2.override_kernel_check=true"
  ]
}
EOF
启动docker并设置开机自启
systemctl daemon-reload
systemctl enable --now docker.service
验证安装结果
systemctl status docker #查看docker服务状态
docker -v #查看docker版本
复制代码

 

posted on   属于我的梦,明明还在  阅读(232)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
< 2025年3月 >
23 24 25 26 27 28 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 1 2 3 4 5

点击右上角即可分享
微信分享提示