Linux环境docker离线安装教程

Linux环境docker离线安装教程

  • [1. 准备离线包](#1. 准备离线包)
  • [2. 准备docker.service 系统配置文件](#2. 准备docker.service 系统配置文件)
  • [3. 准备安装脚本和卸载脚本](#3. 准备安装脚本和卸载脚本)
  • [4. 安装](#4. 安装)
    • [4.1 此时目录为:(只需要关注docker-17.03.2-ce.tgz、docker.service、install.sh、uninstall.sh即可)](#4.1 此时目录为:(只需要关注docker-17.03.2-ce.tgz、docker.service、install.sh、uninstall.sh即可))
    • [4.2 执行脚本sh install.sh docker-17.03.2-ce.tgz](#4.2 执行脚本sh install.sh docker-17.03.2-ce.tgz)
    • [待脚本执行完毕后,执行 docker -v](#待脚本执行完毕后,执行 docker -v)
    • [4.3 如果你想卸载docker,此时执行脚本 sh uninstall.sh 即可](#4.3 如果你想卸载docker,此时执行脚本 sh uninstall.sh 即可)

1. 准备离线包

https://download.docker.com/linux/static/stable/x86_64/

下载需要安装的docker版本,这里已docker-17.03.2-ce.tgz版本为例子。

2. 准备docker.service 系统配置文件

复制代码
[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

3. 准备安装脚本和卸载脚本

安装脚本 install.sh

powershell 复制代码
#!/bin/sh
echo '解压tar包...'
tar -xvf $1
echo '将docker目录移到/usr/bin目录下...'
cp docker/* /usr/bin/
echo '将docker.service 移到/etc/systemd/system/ 目录...'
cp docker.service /etc/systemd/system/
echo '添加文件权限...'
chmod +x /etc/systemd/system/docker.service
echo '重新加载配置文件...'
systemctl daemon-reload
echo '启动docker...'
systemctl start docker
echo '设置开机自启...'
systemctl enable docker.service
echo 'docker安装成功...'
docker -v

卸载脚本 uninstall.sh

powershell 复制代码
#!/bin/sh
echo '删除docker.service...'
rm -f /etc/systemd/system/docker.service
echo '删除docker文件...'
rm -rf /usr/bin/docker*
echo '重新加载配置文件'
systemctl daemon-reload
echo '卸载成功...'

4. 安装

4.1 此时目录为:(只需要关注docker-17.03.2-ce.tgz、docker.service、install.sh、uninstall.sh即可)

4.2 执行脚本sh install.sh docker-17.03.2-ce.tgz

待脚本执行完毕后,执行 docker -v

发现此时docker已安装成功,可以用 docker --help 查看docker命令,从现在开始你就可以自己安装image和container了

4.3 如果你想卸载docker,此时执行脚本 sh uninstall.sh 即可

相关推荐
面对疾风叭!哈撒给1 分钟前
Linux ARM架构的docker和docker-compose离线安装
linux·docker·架构
阿虎儿23 分钟前
Linux 下为局域网 IP(如 192.168.1.100)打造不受浏览器警告的自签名 SSL/TLS 证书
linux·安全·https
小王C语言1 小时前
虚拟机开机过程中关机,再次开机没有分配 IP
linux·网络·tcp/ip
薛定谔的悦1 小时前
光储系统 AEMS 模块的光伏控制模式设计
linux·能源·储能·bms
刹那芳华19922 小时前
基于 Docker 的 LLaMA-Factory 全流程部署指南
docker·容器·llama
码农客栈2 小时前
U-Boot详解(三)之启动流程详解
linux·uboot
say_fall2 小时前
【Linux系统编程】文件操作基础:C标准库、系统调用、fd是什么和fd与FILE*的关系
android·linux·c语言
邪修king2 小时前
Re:Linux系统篇(六):动静态库 & 链接机制【完整透彻版】
linux·运维·服务器
严谨的麻辣烫9 小时前
Linux sysctl 网络参数调优实战:高并发与长连接场景下的内核配置
linux·网络·php
阡陌..12 小时前
Ubuntu 22.04 离线环境完全配置指南:从 GCC 到 NVIDIA 驱动再到 Samba 共享
linux·运维·ubuntu