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 即可

相关推荐
开压路机2 小时前
进程控制
linux·服务器
香蕉鼠片2 小时前
跨平台开发到底是什么
linux·windows·macos
Eric.Lee20214 小时前
docker 启动停止命令
运维·docker·容器
bukeyiwanshui4 小时前
20260417 DNS实验
linux
代码中介商5 小时前
Linux 帮助手册与用户管理完全指南
linux·运维·服务器
苏渡苇6 小时前
5 分钟跑起 Redis(Docker 版)
数据库·redis·缓存·docker·redis入门
weixin_449173657 小时前
Linux -- 项目中查找日志的常用Linux命令
linux·运维·服务器
深念Y8 小时前
赛米尼M02/海纳斯HiNAS系统-WiFi驱动安装教程
运维·服务器·网络·docker·nas·机顶盒·hinas
想唱rap8 小时前
C++智能指针
linux·jvm·数据结构·c++·mysql·ubuntu·bash
Strugglingler8 小时前
基于whiptail开发shell导航工具
linux·shell·ui设计·whiptail