Tools, FAQ, Tutorials:
Remove Log Files of Docker Container
How to remove log files of a Docker container?
✍: FYIcenter.com
If you keep a Docker container running for many days,
it will generate many log files on your hosting system.
You can follow this tutorial to remove old log files of a Docker container.
1. Get the container ID of "peer0.org1.example.com" container:
$ docker inspect peer0.org1.example.com
[
{
"Id": "b812096b622be73f9bdbe0f096b9957e37a53c50746c75952a0b686cee928a19",
"Created": "2019-04-01T01:09:49.607879144Z",
"Path": "peer",
"Args": [
"node",
"start"
],
"State": {
"Status": "running",
"Running": true,
...
2. List the container log file directory:
$ sudo ls -l /var/lib/docker/containers/b812096b622be73f9bdbe0f096b9957e37a53c50746c75952a0b686cee928a19 -rw-r----- 1 56288 Apr 14 17:45 b812096b622be73f9bdbe0f096b9957e37a53c50746c75952a0b686cee928a19-json.log drwx------ 2 4096 Apr 14 01:09 checkpoints -rw------- 1 6788 Apr 14 01:10 config.v2.json -rw-r--r-- 1 1968 Apr 14 01:10 hostconfig.json -rw-r--r-- 1 13 Apr 14 01:09 hostname -rw-r--r-- 1 176 Apr 14 01:09 hosts drwx------ 3 4096 Apr 14 01:09 mounts -rw-r--r-- 1 97 Apr 14 01:09 resolv.conf -rw-r--r-- 1 71 Apr 14 01:09 resolv.conf.hash
3. Truncate the log file to 1 KB, if it is getting too big:
sudo truncate -s 1K /var/lib/docker/containers/b812096b622be73f9bdbe0f096b9957e37a53c50746c75952a0b686cee928a19\ /b812096b622be73f9bdbe0f096b9957e37a53c50746c75952a0b686cee928a19-json.log
⇒ basic-network Sample Network
⇐ Inspect Docker Container Configuration
2020-05-29, ∼1391🔥, 0💬
Popular Posts:
How To Set session.gc_divisor Properly in PHP? As you know that session.gc_divisor is the frequency ...
How to dump (or encode, serialize) a Python object into a JSON string using json.dumps()? The json.d...
What Happens If One Row Has Missing Columns? What happens if one row has missing columns? Most brows...
How to use "{{...}}" Liquid Codes in "set-body" Policy Statement? The "{{...}}" Liquid Codes in "set...
How to add request URL Template Parameters to my Azure API operation 2017 version to make it more us...