Linux系统离线安装Docker
某些时候需要使用Docker环境,但存在服务器无法联网或者其他情况,需要离线安装Dokcer,本次记录Oracle Linux 7环境下安装Docker:
1、下载Docker二进制文件
下载地址:https://download.docker.com/linux/static/stable/x86_64/
选择需要安装的版本,如下载docker-27.2.1
2、使用winSCP或者Xftp工具上传至Linux服务器
3、解压安装包
tar -zxvf docker-27.2.1.tgz
4、将解压出来的docker文件内容拷贝或者移动到 /usr/bin/目录下
cp docker/* /usr/bin/
5、创建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 -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
6、添加文件可执行权限
chmod +x /etc/systemd/system/docker.service
7、配置Docker镜像
在etc下新建docker目录
cd /etc & mkdir docker
创建daemon.json 文件
vim /etc/docker/daemon.json
添加如下镜像源:
{
"registry-mirrors": [
"https://docker.hpcloud.cloud",
"https://docker.m.daocloud.io",
"https://docker.unsee.tech",
"https://docker.1panel.live",
"http://mirrors.ustc.edu.cn",
"https://docker.chenby.cn",
"http://mirror.azure.cn",
"https://dockerpull.org",
"https://dockerhub.icu",
"https://hub.rat.dev",
"https://proxy.1panel.live",
"https://docker.1panel.top",
"https://docker.m.daocloud.io",
"https://docker.1ms.run",
"https://docker.ketches.cn"
]
}
8、启动docker服务
重新加载 daemon 服务
systemctl daemon-reload
启动 docker 服务
systemctl start docker
查看 docker 服务状态
systemctl status docker
查看docker版本
docker -v