离线安装docker

由于在很多情况下需要安装docker的虚拟机或服务器无法访问互联网,因此需要离线安装docker


准备工作

1、一台可以访问互联网的虚拟机或服务器,操作系统不限,改机器可以访问拟安装docker的机器


STEP 1 以下操作在可以访问互联网的机器进行

1、下载安装包 访问https://download.docker.com/linux/static/stable/ 选择合适的版本并下载,笔者用的是 https://download.docker.com/linux/static/stable/x86_64/docker-18.09.6.tgz


STEP 2 将下载的安装包上传到拟安装的机器


STEP 3 以下操作在拟安装的机器上进行

解压缩安装包

tar -zxvf docker-18.09.6.tgz 

复制解压缩后的文件到指定文件夹

 cp docker/* /usr/bin/ 

注册编辑docker服务

vim /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

添加权限后启动

chmod +x /etc/systemd/system/docker.service

重新加载配置文件

systemctl daemon-reload 

启动Docker

systemctl start docker

设置开机自启

systemctl enable docker.service

验证是否安装成功

systemctl status docker
docker -v
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容