Docker container logs taking all my disk space

前端 未结 6 2123
隐瞒了意图╮
隐瞒了意图╮ 2021-01-30 07:53

I am running a container on a VM. My container is writing logs by default to /var/lib/docker/containers/CONTAINER_ID/CONTAINER_ID-json.log file until the disk is full.

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 08:48

    Caution: this post relates to docker versions < 1.8 (which don't have the --log-opt option)

    Why don't you use logrotate (which also supports compression)?

    /var/lib/docker/containers/*/*-json.log {
    hourly
    rotate 48
    compress
    dateext
    copytruncate
    }
    

    Configure it either directly on your CoreOs Node or deploy a container (e.g. https://github.com/tutumcloud/logrotate) which mounts /var/lib/docker to rotate the logs.

提交回复
热议问题