Delete container logs

I need to delete the logs of my containers.

Although this was possible with my old setup (dinghy + virtualbox), I can’t find a way (maybe it’s not possible) to enter the docker machine the delete the logs.

This command

docker inspect --format=‘{{.LogPath}}’ elasticsearch

will produce this output


This command

docker-machine ls

doesn’t provide the machine used so I can ssh it.

These commands

eval $(docker-machine env)
docker-machine ip

produce this output

Error: No machine name(s) specified and no “default” machine exists.

If you delete and recreate your containers, it will reset their logs.

If you’re having this problem, you should also look at the other Docker logging options, and probably switch away from the built-in JSON logger. My application uses a Elasticsearch + Logstash + Kibana setup with a GELF transport, which is reasonable enough (especially if you’re using Elasticsearch for other things); but Logstash is a pretty useful intermediary for this.

You really shouldn’t be manually touching anything inside the /var/lib/docker tree. (Do you manually delete Elasticsearch files that you think are getting too large, or use its API?)

If you do need to get into the (hidden) VM, the magic “screen” command has gotten mentioned several times in the forum already, and I’d recommend the forum search box at the top right.