Linux docker离线部署
1. Docker下载
Docker下载地址:https://mirrors.dahuatech.com/docker-ce/。本文下载当前最新版本,链接如下:https://mirrors.dahuatech.com/docker-ce/linux/static/stable/aarch64/docker-27.4.0.tgz。
2. 安装Docker
将压缩包上传到服务器上之后解压,命令如下:
tar –zxvf docker-27.4.0.tgz
完成后将文件复制到/usr/bin目录中,命令如下:
cp –rf docker/* /usr/bin/
然后就可以使用docker –v之类的命令了,因为没有开启守护进程,所以需要编写docker.service文件,命令如下:
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 -H unix:///var/run/docker.sock --selinux-enabled=false --default-ulimit nofile=65536:65536
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
添加执行权限并启动docker服务:
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker
然后执行docker –v就可以开看到dockers版本了,运行docker ps就可以看到docker已经运行成功。