How to clear the logs properly for a Docker container?

前端 未结 15 2479
谎友^
谎友^ 2020-12-12 09:00

I use docker logs [container-name] to see the logs of a specific container.

Is there an elegant way to clear these logs?

15条回答
  •  一生所求
    2020-12-12 09:31

    On my Ubuntu servers even as sudo I would get Cannot open ‘/var/lib/docker/containers/*/*-json.log’ for writing: No such file or directory

    But combing the docker inspect and truncate answers worked :

    sudo truncate -s 0 `docker inspect --format='{{.LogPath}}' `
    

提交回复
热议问题