0

I have a simple question: what will happen if I delete a Docker container log file? As we know Docker stores container log under /var/lib/docker/containers/*/*-json.log. If by chance I deleted that <container_name>-json.log then what will happen? Docker will create a new log file or it will stop writing logs?

David Maze
  • 130,717
  • 29
  • 175
  • 215
  • 2
    Try it and let us know :-) – BertC Apr 20 '22 at 14:19
  • My initial guess is that it's the same as any other Un*x file that's deleted while it's open for write: Docker will continue writing to the deleted file and it will keep taking up disk space, but it will not have an entry in the filesystem. I haven't verified this, though. How does your application code take advantage of this; can you include a code sample? – David Maze Apr 20 '22 at 15:38
  • If you're having an issue with docker logs taking too much space, I'd suggest setting up automatic log rotation: https://stackoverflow.com/questions/42510002/docker-how-to-clear-the-logs-properly-for-a-docker-container – Nick ODell Apr 20 '22 at 15:46

0 Answers0