Here’s how to delete your Docker container log files.
Get Docker File Location
1. Run docker inspect
to find your Docker log file location
2. Find the “Docker Root Dir” Value, mine is /var/lib/docker
Windows
On Windows, Docker runs in a VM called MobyLinuxVM, but you cannot login to that VM via Hyper-V Manager. We’ll create a container that has full root access and then access the file system from there. See my post “How to SSH into the Docker VM (MobyLinuxVM) on Windows” for instructions on how to do that.
Delete Log Files
Open a terminal and run the following:
Your docker log file path should be /var/lib/docker, but if it isn’t, then change it in the command below.
find /var/lib/docker/containers/ -type f -name "*.log" -delete
Thanks to Stefan Foulis for originally posting this code here: https://gist.github.com/stefanfoulis/604ea00fd66eea03607b
Troubleshooting
1. Prefix the find
command with sudo
if you get a permission denied message.
2. Execute sudo -i
if you see sudo user error messages.
Jon