Linux离线安装Docker
查看服务器架构信息
uname -m
下载安装包并传输到指定服务器
- 访问https://download.docker.com/linux/static/stable/ 下载对应服务器架构下的压缩包,架构目录下有对应的docker版本
解压并拷贝命令
# 解压安装包
tar -zxvf docker-aarch64-24.0.5.tgz# 将解压出来的docker文件复制到 /usr/bin/ 目录下
cp docker/* /usr/bin/
配置systemd服务
- 由于不同的系统,服务管理器的方式和工具不一样,请各位自行查询一下自己的系统对应服务管理器该如何配置
- centos7和openeuler: systemd
- 进入/etc/systemd/system/目录,并创建docker.service文件
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target
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 --selinux-enabled=false
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 777 /etc/systemd/system/docker.service
- 重新加载配置文件(每次有修改docker.service文件时都要重新加载下)
systemctl daemon-reload
配置docker数据目录
没有特殊需求的话,可以跳过这一步;当然也可以修改,下面是修改docker数据目录的方式
- 默认docker镜像下载目录为/var/lib/docker,我们可以修改为其他目录,比如/data/docker
mkdir /data/docker
- 修改docker配置文件/etc/docker/daemon.json
{"data-root": "/data/docker"
}
- 启动docker服务
systemctl start docker
启停docker服务
- 启动docker服务
systemctl start docker
- 设置开机启动
systemctl enable docker.service
- 查看docker状态
systemctl status docker
- 验证
systemctl status docker