保姆级离线环境安装docker和docker-compose
参考:https://www.cnblogs.com/timlong/p/12980351.html
https://blog.csdn.net/qq_40784783/article/details/112307745
(1)下载准备好docker安装包
docker所有版本:
https://download.docker.com/linux/static/stable/
(2)解压
cd /opt
mkdir docker
上传docker
tar -xvf docker-23.0.tgz(文件传输工具xftp传文件夹)
添加权限 chmod 755 docker/*
(3)将解压出来的docker文件内容移动到/usr/bin/目录下
将docker目录拷贝到/user/bin下(会提示是否覆盖/usr/bin/runc,覆盖即可
cp docker/* /usr/bin/
y
ls -l /usr/bin/docker*
(4)新增docker配置文件
mkdir /etc/docker
cd /etc/docker
vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://ab8zvf16.mirror.aliyuncs.com"]
}
(5)将docker注册为service
vi /usr/lib/systemd/system/docker.service
(选的这个路径)/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
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
——————————————————————————————————
sudo chmod +x /etc/systemd/system/docker.service
(6)启动
systemctl daemon-reload #重载unit配置文件
systemctl start docker #启动Docker
systemctl enable dockerd.service #设置开机自启
(7)验证
systemctl status docker #查看Docker状态
docker -v #查看Docker版本
Compose环境安装(离线安装)
1.docker-compose-Linux-x86_64 上传到服务器中,然后执行如下命令将其移动到/usr/local/bin/目录中 并且更名为docker-compose
mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
2.执行如下命令:添加可执行的权限
sudo chmod +x /usr/local/bin/docker-compose
3.验证docker-compose
docker-compose -v