一、Docker 离线安装
1. 下载docker tar.gz包
下载地址: Index of linux/static/stable/x86_64/
本文选择版本:23.0.6
2.创建docker.service文件
vi docker.service文件内容如下:
[Unit]
Description=Docker Application Container Engine
After=network-online.target firewalld.service
Wants=network-online.target[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s[Install]
WantedBy=multi-user.target
3. 一键安装脚本
注意: 安装脚本和docker.service文件放在安装包的同级目录下
vi install_docker.sh
#!/bin/sh
echo '解压tar包...'
tar_file=$1
if [ -f $tar_file ];thentar -zxvf $tar_fileecho '将docker目录移到/usr/bin目录下...'cp docker/* /usr/bin/echo '将docker.service 移到/etc/systemd/system/ 目录...'cp docker.service /etc/systemd/system/echo '添加文件权限...'chmod +x /etc/systemd/system/docker.serviceecho '重新加载配置文件...'systemctl daemon-reloadecho '启动docker...'systemctl start dockerecho '设置开机自启...'systemctl enable docker.serviceecho 'docker安装成功...'docker -v
elseecho "$tar_file,文件不存在"
fi
4. 执行脚本
chmod +x install_docker.sh
./install_docker.sh tar包路径
解压tar包...
docker/
docker/docker-proxy
docker/containerd-shim-runc-v2
docker/ctr
docker/docker
docker/docker-init
docker/runc
docker/dockerd
docker/containerd
将docker目录移到/usr/bin目录下...
将docker.service 移到/etc/systemd/system/ 目录...
添加文件权限...
重新加载配置文件...
启动docker...
设置开机自启...
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /etc/systemd/system/docker.service.
docker安装成功...
Docker version 23.0.6, build ef23cbc
[root@localhost docker-run-envirment]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
安装完成!
二、docker-compose安装
1、安装docker-compose
注意:要安装其他版本的Compose,可以将1.29.2替换为要安装的Compose版本
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
2、申请可执行权限
$ sudo chmod +x /usr/local/bin/docker-compose
3、查看docker-compose版本
$ docker-compose --version