How to clear the logs properly for a Docker container?

前端 未结 15 2496
谎友^
谎友^ 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:46

    Not sure if this is helpful for you, but removing the container always helps.

    So, if you use docker-compose for your setup, you can simply use docker-compose down && docker-compose up instead of docker-compose restart. With a proper setup (make sure to use volume mounts for persistent data), you don't lose any data this way.

    Sure, this is more than the OP requested. But there are various situations where the other answers cannot help (if using a remote docker server or working on a Windows machine, accessing the underlying filesystem is proprietary and difficult)

提交回复
热议问题