How to clear the logs properly for a Docker container?

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

    Docker for Mac users, here is the solution:

      1. Find log file path by:

        $ docker inspect | grep log

      1. SSH into the docker machine( suppose the name is default, if not, run docker-machine ls to find out):

        $ docker-machine ssh default

      1. Change to root user(reference):

        $ sudo -i

      1. Delete the log file content:

        $ echo "" > log_file_path_from_step1

提交回复
热议问题