docker运行磁盘空间不足no space left on device

发布于 2022-06-30  35.08k 次阅读


docker restart seata
Error response from daemon: Cannot restart container seata: open /var/lib/docker/containers/af467a4f04568120f1fc48f04f583a0f4f37b938dd28ae0e85a0e9
0f54eff57b/hash2148010767: no space left on device

重启docker的时候发现磁盘空间不足,logstash日志太大导致

docker运行磁盘空间不足no space left on device

解决方法:

1、先清理日志

cat /dev/null > /var/lib/docker/containers/af467a4f04568120f1fc48f04f583a0f4f37b938dd28ae0e85a0e90f54eff57b/af467a4f04568120f1fc48f04f583a0f4f37b938dd28ae0e85a0e90f54eff57b.log

2、限制容器日志大小

[root@home]# docker run -it --log-opt max-size=10m --log-opt max-file=3 xxx

--log-driver local 用来区分存储方式

https://docs.docker.com/config/containers/logging/json-file/

用docker-compose的话,则格式为

services:
  logstash:
    logging:
      options:
        log-driver: local/json-file/logentries
        max-size: 100m
        max-file: 3