linux离线安装docker

需求:

服务器部署是在内网,无法连接外网,所以特地记录下离线安装docker

实践:

一、rpm包方式

1、下载rpm离线安装包

个人提供的云盘地址(没有密码):https://www.aliyundrive.com/s/uUwHAdm3XMa

也可以去下面的官网地址下载:
官方下载地址:https://download.docker.com/linux/centos/7/x86_64/stable/Packages/

2、上传离线安装包

将两个rpm离线包上传到同一个目录下。我这里直接放在了/home/docker下
在这里插入图片描述

3、通过Yum安装Docker包
sudo yum install *.rpm
4、开启Docker服务
# 设置自启动
sudo systemctl enable docker
# 开启服务
sudo systemctl start docker
5、查看docker状态
sudo systemctl status docker

linux离线安装docker_第1张图片

二、tgz包方式(推荐用这个)

1、下载tgz离线安装包

下载地址:https://download.docker.com/linux/static/stable/x86_64/
我们这里下载的是docker-18.09.7.tgz (根据自己系统版本下载)
在这里插入图片描述

2、上传到服务器并解压
tar -zxvf docker-18.09.7.tgz 
3、复制到/usr/bin
cp docker/* /usr/bin
4、将docker设置成服务
#新建服务
vi /etc/systemd/system/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
5、启动服务
#添加文件权限并启动docker
chmod +x /etc/systemd/system/docker.service
#重载unit配置文件
systemctl daemon-reload
#启动docker
systemctl start docker       
#设置开机自启
systemctl enable docker.service
6、查看状态
systemctl status docker

参考:

CentOS7离线安装Docker
https://cookcode.blog.csdn.net/article/details/80158997?spm=1001.2014.3001.5506
redhat 离线安装 docker
https://blog.csdn.net/zzwpublic/article/details/107397212?spm=1001.2014.3001.5506

你可能感兴趣的:(应用部署,docker,linux,容器)