How to clear the logs properly for a Docker container?

前端 未结 15 2489
谎友^
谎友^ 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条回答
  •  萌比男神i
    2020-12-12 09:49

    You can't do this directly through a Docker command.

    You can either limit the log's size, or use a script to delete logs related to a container. You can find scripts examples here (read from the bottom): Feature: Ability to clear log history #1083

    Check out the logging section of the docker-compose file reference, where you can specify options (such as log rotation and log size limit) for some logging drivers.

提交回复
热议问题