Skip to content

Instantly share code, notes, and snippets.

@DManavi
Created August 21, 2020 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DManavi/d063fea8f0acb9395c7f1396e035f1b7 to your computer and use it in GitHub Desktop.
Save DManavi/d063fea8f0acb9395c7f1396e035f1b7 to your computer and use it in GitHub Desktop.
Clear container logs in docker

How to Clear container logs in docker

After a few months of running your containers, you may need to cleanup the logs. Since these are text logs, after a while, they take a huge amount of hard disk on your host machine. To remove these logs, you can run the command below.

  $ truncate -s 0 $(docker inspect --format='{{.LogPath}}' <your-container-name>)

Let's assume that your container is named 'my-container' so that the command will be

  $ truncate -s 0 $(docker inspect --format='{{.LogPath}}' my-container)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment