Docker container logs taking all my disk space

前端 未结 6 2128
隐瞒了意图╮
隐瞒了意图╮ 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:57

    Pass log options while running a container. An example will be as follows

    sudo docker run -ti --name visruth-cv-container  --log-opt max-size=5m --log-opt max-file=10 ubuntu /bin/bash
    

    where --log-opt max-size=5m specifies the maximum log file size to be 5MB and --log-opt max-file=10 specifies the maximum number of files for rotation.

提交回复
热议问题