docker内存满了

编程入门 行业动态 更新时间:2024-10-21 06:02:58

docker内存<a href=https://www.elefans.com/category/jswz/34/1729246.html style=满了"/>

docker内存满了

启动docker容器不带日志

docker run 的时候加上参数 --log-driver=“none”。

查看磁盘使用情况

df -lh (查看磁盘使用情况)

查看各个目录使用情况

du -h --max-depth=2 (目录检索深度)

批量删除

find / -name *-json.log |xargs rm -rf

查找大于某个大小

find / -type f -size +1G

清理docker-log命令

echo “==================== start clean docker containers logs ==========================”

logs=$(find /var/lib/docker/containers/ -name *-json.log)

for log in $logs
do
echo “clean logs : $log”
cat /dev/null > $log
done

echo “==================== end clean docker containers logs ==========================”

remove exited containers:

docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v

remove unused images:

local images=docker images --no-trunc;
local lines= ( e c h o " (echo " (echo"images" | awk ‘{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 2}̲' | grep -n "<n…/p/g’);
lines=echo $lines;
lines= l i n e s / / / ; ; l o c a l i m a g e i d s = {lines// /;}; local image_ids= lines///;;localimagei​ds=(echo “$images” | awk '{print KaTeX parse error: Expected 'EOF', got '}' at position 2: 3}̲' | sed -n "lines");
[[ -n “${image_ids[@]}” ]] && docker rmi ${image_ids[@]}

remove unused volumes:

find ‘/var/lib/docker/volumes/’ -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
docker ps -aq | xargs docker inspect | jq -r ‘.[] | .Mounts | .[] | .Name | select(.)’
) | xargs -r rm -fr

。。。。

更多推荐

docker内存满了

本文发布于:2023-06-29 09:20:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/942684.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:满了   内存   docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!