sakuraidc 发表于 2025-3-22 17:44:42

宝塔docker 获取容器日志卡死如何解决?

<strong>原因</strong><div align="left"><font style="color:rgb(78, 83, 88)"><font face="&amp;quot;"><font style="font-size:16px">这个问题主要是容器的日志过大,再加上宝塔默认获取的是全部日志,导致的卡死。按下列步骤即可解决</font></font></font></div><strong>1.查看日志文件大小</strong><font style="color:rgb(85, 85, 85)"><br />
<br />
<br />
<br />
<font style="font-size:10px"><font style="color:rgb(170, 170, 170)"><font style="color:rgb(85, 85, 85)"><font face="inherit"><font style="font-size:13px">find /var/lib/docker/containers/ -name *-json.</font></font></font><font style="color:rgb(0, 134, 179)"><font face="inherit"><font style="font-size:13px">log</font></font></font><font style="color:rgb(85, 85, 85)"><font face="inherit"><font style="font-size:13px"> -exec ls -lh </font></font></font><font style="color:rgb(119, 119, 119)"><font face="inherit"><font style="font-size:13px">{}</font></font></font><font style="color:rgb(85, 85, 85)"><font face="inherit"><font style="font-size:13px"> \;</font></font></font><br />
</font><br />
</font><br />
</font><br />
<div align="left"><font style="color:rgb(78, 83, 88)"><font face="&amp;quot;"><font style="font-size:16px"><img id="aimg_dGGF7" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" height="100" src="https://www.sakuraidc.cc/wp-content/uploads/2025/03/20250322123605588-1000019662-1024x155.jpg" border="0" alt="" /></font></font></font></div><strong>2.清空日志</strong><font style="color:rgb(85, 85, 85)"><br />
<br />
<br />
<br />
<font style="font-size:10px"><font style="color:rgb(170, 170, 170)"><font style="color:rgb(85, 85, 85)"><font face="inherit"><font style="font-size:13px">docker ps -aq </font></font></font><font style="color:rgb(119, 119, 119)"><font face="inherit"><font style="font-size:13px">|</font></font></font><font style="color:rgb(85, 85, 85)"><font face="inherit"><font style="font-size:13px"> xargs docker inspect --format=</font></font></font><font style="color:rgb(241, 67, 110)"><font face="inherit"><font style="font-size:13px">'{{.LogPath}}'</font></font></font><font style="color:rgb(85, 85, 85)"><font face="inherit"><font style="font-size:13px"> </font></font></font><font style="color:rgb(119, 119, 119)"><font face="inherit"><font style="font-size:13px">|</font></font></font><font style="color:rgb(85, 85, 85)"><font face="inherit"><font style="font-size:13px"> xargs truncate -s </font></font></font><font style="color:rgb(0, 153, 153)"><font face="inherit"><font style="font-size:13px">0</font></font></font><br />
</font><br />
</font><br />
</font><br />
<div align="left"><font style="color:rgb(78, 83, 88)"><font face="&amp;quot;"><font style="font-size:16px"><img id="aimg_DXXPs" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" height="100" src="https://www.sakuraidc.cc/wp-content/uploads/2025/03/20250322123737285-1000019664-1024x226.jpg" border="0" alt="" /></font></font></font></div><strong>3.再次查看日志大小</strong><div align="left"><font style="color:rgb(78, 83, 88)"><font face="&amp;quot;"><font style="font-size:16px">可以看到已经变为零了</font></font></font></div><div align="left"><font style="color:rgb(78, 83, 88)"><font face="&amp;quot;"><font style="font-size:16px">这时候我们在打开宝塔的容器日志就不会卡死了</font></font></font></div><br />
页: [1]
查看完整版本: 宝塔docker 获取容器日志卡死如何解决?