Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear logs in native Docker on Mac

I want to get rid of huge container log files on my docker env.

I have problem finding them when running native Docker on a Mac. I am not using docker-machine (virtualbox) thing. My docker version is 1.13.1.

When I do

docker inspect <container-name>

I see there is

"LogPath": "/var/lib/docker/containers/<container-id>/<container-id>-json.log

But there is not even directory /var/lib/docker on my mac (host).

I have also looked in

~/Library/Containers/com.docker.docker/

but didn't find any container specific loggings there.

I could use tail, but it is not that convenient always to me.

So the question is, how can I clear the log files of my containers on my native Docker Mac environment.

like image 804
Axel Janduneaz Avatar asked Mar 01 '17 08:03

Axel Janduneaz


People also ask

Where are docker logs stored in Mac?

Docker Daemon Log File If you really want the hard core alternative, then the log files are available at: ~/Library/Containers/com. docker. docker/Data/com.

How do I factory reset my Mac docker?

To begin with, open the Docker Desktop app and head to the dashboard. Then, select the Troubleshoot icon and click Reset to factory defaults. Next, click the Yes, reset anyway and the task is done.

How do I view all docker logs?

First of all, to list all running containers, use the docker ps command. Then, with the docker logs command you can list the logs for a particular container. Most of the time you'll end up tailing these logs in real time, or checking the last few logs lines.


1 Answers

This is the only solution that worked for macOS 10.14

docker run -it --rm --privileged --pid=host NAME nsenter -t 1 -m -u -n -i -- sh -c 'truncate -s0 /var/lib/docker/containers/*/*-json.log'

Replace NAME with your container name

Hope this helps

like image 63
Raj Nandan Sharma Avatar answered Sep 19 '22 13:09

Raj Nandan Sharma