当前位置: 首页 > news >正文

最简单的Docker离线安装教程

最简单的Docker离线安装教程

  • 方式一 RPM 包方式
    • 1. 在线下载 RPM 包
    • 2. 将 RPM 包拷贝到安装机器
    • 3. 安装
    • 4. 启动
  • 方式二 二进制安装方式(推荐)
    • 1. 下载包
    • 2. 将包进行解压授权
    • 3. 注册 systemd
    • 4. 自启和启动

一直以来在线安装 docker 到服务器上是非常方便的,但是经常会遇到服务器无法直接通互联网,因为需要我们离线安装。本文提供两种离线安装的方式。

方式一 RPM 包方式

1. 在线下载 RPM 包

先找一台可以连接互联网的电脑,下载 RPM 包,电脑的版本最好和要安装的服务器版本一致。执行如下步骤

  1. 下载RPM包方式&安装RPM包方式
# 安装
yum install -y yum-utils# 配置 yum docker 源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast# 下载rpm包,包括依赖都会下载
yumdownloader --resolve --downloadonly docker-ce-19.03.9 docker-ce-cli-19.03.9 docker-compose \
audit audit-libs audit-libs-python containerd.io container-selinux libcgroup python-IPy  \
setools-libs checkpolicy  libsemanage-python policycoreutils

2. 将 RPM 包拷贝到安装机器

怎么拷贝都行,将RPM 包放到服务器的某一个目录就行

3. 安装

# 将 rpm 包安装
rpm -ivh --replacefiles --replacepkgs *.rpm

4. 启动

systemctl enable docker && systemctl start docker后面使用跟在线安装一样了

方式二 二进制安装方式(推荐)

1. 下载包

去官方地址下载 docker 包 https://docs.docker.com/engine/install/binaries/

2. 将包进行解压授权

# 解压
tar -zxvf docker-19.03.9.tgz --strip-components=1 --directory /usr/bin/# 文件授权
chown root:root /usr/bin/containerd /usr/bin/containerd-shim /usr/bin/ctr /usr/bin/docker /usr/bin/dockerd /usr/bin/docker-init /usr/bin/docker-proxy /usr/bin/runc

3. 注册 systemd

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

4. 自启和启动

启动
systemctl daemon-reload && systemctl enable docker && systemctl start docker
http://www.lryc.cn/news/397404.html

相关文章:

  • 如何在 Python 中创建一个类似于 MS 计算器的 GUI 计算器
  • 警惕:与ChatGPT共享业务数据可能十分危险
  • 基于MacOS系统Sonoma 14.5的SSH服务禁止密码登录
  • 深入理解MySQL中的EXPLAIN及type列
  • LoRaWAN网络协议Class A/Class B/Class C三种工作模式说明
  • ITSS服务经理:WAVE SUMMIT深度学习开发者大会2024在北京召开
  • Keysight 是德 DSAX93204A 高性能示波器
  • oracle逻辑层级详解(表空间、段、区、数据块)
  • 华为OD机试(C卷,200分)- 字符串拼接、田忌赛马
  • Windows中配置python3.11环境安装教程
  • 市场趋势的智能预测:Kompas.ai如何洞察未来市场动向
  • 华南师范大学“大学生校外实践教学基地”授牌仪式暨见习参观活动圆满结束
  • 防爆定位信标适合工厂吗?都有哪些优势呢?
  • 行为模式8.状态模式------灯泡状态切换
  • Linux账户和组管理——账户和工作组分类,用户账号文件,/etc/passwd文件中7个字段,id 命令
  • 《大明混一图》: 令人叹为观止的古代世界地图
  • Java高级重点知识点-22-缓冲流、转换流、序列化流、打印流
  • express民族民俗文化分享平台-计算机毕业设计源码22552
  • Web 基础与HTTP 协议
  • C++超市外卖小程序-计算机毕业设计源码62482
  • 合合信息“大模型加速器”亮相2024世界人工智能大会
  • 2024.07.03校招 实习 内推 面经
  • MySQL中的DDL语句
  • ENSP-防火墙小实验
  • PHP微信小程序视频图文流量主变现小程序系统源码
  • PHP智慧社区小区物业管理系统小程序源码
  • 手撸俄罗斯方块(五)——游戏主题
  • 【测试开发】--安全渗透测试
  • AMEYA360:类比半导体三款车规级新品介绍
  • 内衣洗衣机哪个牌子好用?五大硬核宝藏内衣洗衣机推荐