docker二进制安装

docker自动安装脚本

下载软件

wget https://download.docker.com/linux/static/stable/x86_64/docker-24.0.5.tgz
wget https://github.com/docker/compose/releases/download/v2.21.0/docker-compose-linux-x86_64

1.安装docker和docker-compose

将安装脚本install.sh 和 二进制安装包放置同一个文件夹下
[root@k8s-node2 docker]# ls
docker-24.0.5.tgz docker-compose-linux-x86_64 docker.service install.sh uninstall.sh
[root@k8s-node2 docker]# cat install.sh
#!/bin/sh
echo '解压tar包...'
sudo tar -xvf $1
echo '将docker目录移到/usr/bin目录下...'
sudo cp docker/* /usr/bin/
echo '将docker.service 移到/etc/systemd/system/ 目录...'
sudo cp docker.service /etc/systemd/system/
echo '添加文件权限...'
sudo chmod +x /etc/systemd/system/docker.service
echo '重新加载配置文件...'
sudo systemctl daemon-reload
echo '启动docker...'
sudo systemctl start docker
echo '设置开机自启...'
sudo systemctl enable docker.service
echo 'docker安装成功...'
docker -v
echo '安装docker-compose...'
sudo chmod a+x docker-compose
sudo cp docker-compose-linux-x86_64 /usr/local/bin/docker-compose
echo 'docker-compose安装成功...'
docker-compose version
[root@k8s-node2 docker]# cat docker.service
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
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

2.卸载docker和docker-compose

[root@k8s-node2 docker]# cat uninstall.sh
#!/bin/sh
echo '删除docker.service...'
sudo rm -f /etc/systemd/system/docker.service
echo '删除docker文件...'
sudo rm -rf /usr/bin/docker*
sudo rm -rf /usr/bin/docker-compose
echo '重新加载配置文件'
sudo systemctl daemon-reload
echo '卸载成功...'
posted @   w'dwd  阅读(259)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示