0
点赞
收藏
分享

微信扫一扫

Docker系列---【离线安装指定版本的docker】

1.卸载老版本的docker

yum remove docker  docker-client  docker-client-latest

2.下载docker安装包

去官网下载docker 安装二进制包,选择适合自己的版本。这里下载的是docker-19.03.3.tgz,在centos7中安装(cento6无法使用,提示linux版本内核版本太低)

下载地址:​​https://download.docker.com/linux/static/stable/x86_64/​​

3.上传到服务器上

4.创建docker.service文件,放在和docker安装包同级的目录下。

vi 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

5.创建安装脚本install.sh

vi install.sh
#!/bin/sh

echo '解压tar包...'
sudo tar -zxvf $1
echo '将docker目录移到/usr/bin目录下...'
cp -f docker/* /usr/bin/
echo '将docker.service 移到/etc/systemd/system/ 目录...'
cp -f 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

6.执行安装脚本install.sh

sh install.sh docker-19.03.3.tgz

7.卸载脚本uninstall.sh

vi uninstall.sh
#!/bin/sh
echo '删除docker.service...'
sudo rm -f /etc/systemd/system/docker.service
echo '删除docker文件...'
sudo rm -rf /usr/bin/docker*
echo '重新加载配置文件'
sudo systemctl daemon-reload
echo '卸载成功...'

 

举报

相关推荐

0 条评论