站内公告:

我们的虚拟社区正式开通了

Main Menu

docker离线安装

作者 jvip_chen, 2022-1月-14 09:44 上午

« 上一篇主题 - 下一篇主题 »

jvip_chen

有时候docker运行环境连不了互联网,怎么安装呢?这里介绍docker 离线安装方法,非常简单,只需要一个下载包和几个命令就能搞好!

1、去官网下载docker 安装二进制包,选择适合自己的版本。这里下载的是docker-19.03.9.tgz,在centos7中安装(cento6无法使用,提示linux版本内核版本太低)

下载地址:https://download.docker.com/linux/static/stable/x86_64/

2、复制docker-19.03.9.tgz到服务器上,解压:tar xzvf docker-19.03.9.tgz

3、进入docker目录复制所有文件到/usr/bin目录下,目的/user/bin是环境变量目录,在路径下都可以运行docker命令
ls -l docker
cp docker/* /usr/bin/
[root@localhost local]# tar xvf docker-19.03.9.tgz
docker/
docker/docker-init
docker/runc
docker/docker
docker/docker-proxy
docker/containerd
docker/ctr
docker/dockerd
docker/containerd-shim
[root@localhost local]# ls -l docker
total 195504
-rwxr-xr-x. 1 lr lr 32751272 May 14 17:29 containerd
-rwxr-xr-x. 1 lr lr  6012928 May 14 17:29 containerd-shim
-rwxr-xr-x. 1 lr lr 18194536 May 14 17:29 ctr
-rwxr-xr-x. 1 lr lr 61113382 May 14 17:29 docker
-rwxr-xr-x. 1 lr lr 68874208 May 14 17:29 dockerd
-rwxr-xr-x. 1 lr lr  708616 May 14 17:29 docker-init
-rwxr-xr-x. 1 lr lr  2928514 May 14 17:29 docker-proxy
-rwxr-xr-x. 1 lr lr  9600696 May 14 17:29 runc
[root@localhost local]# mv docker/* /usr/bin/
[root@localhost local]#
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
#开机启动
systemctl enable docker.service
启动docker
systemctl start docker