前言
- 一般人最好用的修復(fù)漏洞的方式就是更新版本
- 起因是使用的Docker版本被檢測(cè)出來(lái)有一堆漏洞(例如:Docker 操作系統(tǒng)命令注入漏洞(CVE-2019-5736))
- 更新環(huán)境無(wú)法聯(lián)網(wǎng),只能通過(guò)下載二進(jìn)制文件的形式進(jìn)行安裝
步驟
- 可先通過(guò)
which docker
查看Docker可執(zhí)行文件的地址 - 然后查看自己docker的版本:
docker versino
- 停止并卸載原有Docker:
systemctl stop docker # 停止Docker服務(wù)
yum remove docker docker-common docker-selinux docker-engine # 卸載Docker(適用于CentOS)
- 下載二進(jìn)制文件:https://download.docker.com/linux/static/stable/x86_64/
- 注意選擇一個(gè)和原本Docker兼容的版本,具體啥兼容我也不知道,反正不要一次性版本更新太多,我第一次從19升級(jí)到24,然后后面死活構(gòu)建不了鏡像,最后選擇了個(gè)20的最新版本,才成功構(gòu)建鏡像
- 解壓縮:
tar xf docker-xxxxx.tgz
- 復(fù)制文件:
cp docker/* /usr/bin/
- 后面這個(gè)地址指的是docker可執(zhí)行文件的地址,默認(rèn)是/usr/bin/目錄下
- 若提示覆蓋,則選擇覆蓋即可
- 設(shè)置開(kāi)機(jī)自啟:
vi /etc/systemd/system/docker.service
,內(nèi)容如下
[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
- 給執(zhí)行權(quán)限
# 給執(zhí)行權(quán)限
chmod +x /etc/systemd/system/docker.service
# 重新加載配置
systemctl daemon-reload
# 設(shè)置開(kāi)機(jī)啟動(dòng)
systemctl enable docker.service
# 進(jìn)行啟動(dòng)
systemctl start docker
- 如果此時(shí)有報(bào)錯(cuò),看看containered組件是否啟動(dòng)
# 查看containerd狀態(tài)
systemctl status containerd
# 啟動(dòng)containerd服務(wù)
systemctl start containerd
- 最后如果所有容器啟動(dòng)成功,通過(guò)
Docker -version
查看版本
提醒
- 中間遇到了很多奇奇怪怪的Bug,就一點(diǎn),先百度,百度解決不了就重啟,注意不要隨便用rm命令刪除數(shù)據(jù)文件
- 比如Docker啟動(dòng)不了,直接重啟虛擬機(jī)
- 如果容器啟動(dòng)不了,報(bào)啥端口占用啥的,直接重啟Docker
參考
- https://www.jianshu.com/p/84b51ad0c1bc
- https://blog.csdn.net/zhanghan18333611647/article/details/112056272
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-572477.html
文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-572477.html
到了這里,關(guān)于修復(fù)漏洞(一)離線升級(jí)Docker版本的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!