{"id":126333,"date":"2024-07-21T19:56:59","date_gmt":"2024-07-21T19:56:59","guid":{"rendered":"https:\/\/linuxiac.com\/?p=126333"},"modified":"2024-07-22T14:38:38","modified_gmt":"2024-07-22T14:38:38","slug":"reducing-docker-logs-file-size","status":"publish","type":"post","link":"https:\/\/linuxiac.com\/reducing-docker-logs-file-size\/","title":{"rendered":"Reducing Docker Logs Size: A Practical Guide to Log Management"},"content":{"rendered":"\n<p>Docker is an excellent tool for quickly setting up and running our needed applications. However, we often overlook a crucial aspect of its operation: the logs it produces.<\/p>\n\n\n\n<p>Why do I say that? Recently, I discovered that one of my servers was running out of free disk space, almost hitting a critical low. Upon investigating, I found that a Docker container had accumulated a 14 GB log file over just a year.<\/p>\n\n\n\n<p>So that you don&#8217;t fall into a similar situation, this guide will help you learn how to check the sizes of all Docker log files quickly, shrink them if needed, and set up Docker to prevent them from getting too big in the future.<\/p>\n\n\n\n<p>Docker containers are stateless, meaning their logs are deleted when the container is recreated. But many overlook a crucial detail here. So, before we proceed, let&#8217;s clarify an important point.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Restart vs. Recreate Docker Container<\/h2>\n\n\n\n<p>Let&#8217;s return to the case above. Over the past year, the server has been restarted multiple times, meaning that Docker containers have also been stopped and started. However, their log files have persisted and continued to grow.<\/p>\n\n\n\n<p>The answer to why this happened is that we are talking about restarting here and not recreating the containers. When the server is rebooted, the Docker daemon gracefully shuts down the running containers, and after boot, it starts them automatically if they&#8217;re set to do so.<\/p>\n\n\n\n<p>Similarly, the behavior is the same when manually restarting the Docker service using the &#8220;systemctl restart docker&#8221; command. It&#8217;s important to understand that <strong>Docker logs are only reset when the Docker container is deleted and recreated. Simply stopping and starting the container does not reset the logs.<\/strong><\/p>\n\n\n\n<p>Having cleared that up, let&#8217;s get to the meat of this guide and learn how to quickly check how much space Docker container logs use on our system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Checking Docker Log Sizes<\/h2>\n\n\n\n<p>Docker logs are typically saved (if you have not explicitly <a href=\"https:\/\/linuxiac.com\/how-to-change-docker-data-directory\/\">changed Docker\u2019s default data directory<\/a>) in the following location on the host machine:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">\/var\/lib\/docker\/containers\/<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">container-id<\/span>&gt;<\/span>\/<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">container-id<\/span>&gt;<\/span>-json.log<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Each Docker container has its directory under &#8220;<em>\/var\/lib\/docker\/containers\/<\/em>.&#8221; Within each container&#8217;s directory, you&#8217;ll find a file ending in &#8220;<em>-json.log<\/em>,&#8221; which contains the logs for that specific container.<\/p>\n\n\n\n<p>These files are structured in JSON format by default and capture the container&#8217;s standard output (stdout) and standard error (stderr) streams.<\/p>\n\n\n\n<p>To find out the size of all Docker container logs sorted from largest to smallest, you can use the following <a href=\"https:\/\/linuxiac.com\/find-files-in-linux\/\" data-type=\"post\" data-id=\"37488\"><code>find<\/code> command<\/a>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">find \/var\/lib\/docker\/containers\/ -name <span class=\"hljs-string\">\"*json.log\"<\/span> | xargs du -h | sort -hr<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-01.jpg\"><img decoding=\"async\" width=\"1024\" height=\"651\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-01-1024x651.jpg\" alt=\"Find out the size of all Docker container logs.\" class=\"wp-image-126519\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-01-1024x651.jpg 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-01-380x242.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-01-768x488.jpg 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-01.jpg 1192w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Find out the size of all Docker container logs.<\/figcaption><\/figure>\n\n\n\n<p>Great, now we have all the log file sizes from our Docker containers. But how do we match these IDs to the actual names of the containers to identify which one produced each log file? Here&#8217;s how.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Find Docker\u2019s Container Name by Its ID<\/h2>\n\n\n\n<p>Let&#8217;s say we want to identify the Docker container responsible for creating the biggest log file listed earlier, which is 5.9M in size. We&#8217;ll use its ID, which is &#8220;<em>d2e9228f92b66ac09fa35dcab36abba2eb4a7f46baa1d03b65d71ed8d42de977<\/em>.&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-02.jpg\"><img decoding=\"async\" width=\"1024\" height=\"159\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-02-1024x159.jpg\" alt=\"Find Docker\u2019s container name by Its ID.\" class=\"wp-image-126534\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-02-1024x159.jpg 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-02-380x59.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-02-768x119.jpg 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-02.jpg 1192w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>The command we need is:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">docker inspect --format=<span class=\"hljs-string\">'{{.Name}}'<\/span> &lt;container_id&gt;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>So, we take the string containing the container ID and put it into the given command.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">docker inspect --format=<span class=\"hljs-string\">'{{.Name}}'<\/span> d2e9228f92b66ac09fa35dcab36abba2eb4a7f46baa1d03b65d71ed8d42de977<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>And just like that, the magic happens. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-03.jpg\"><img decoding=\"async\" width=\"1024\" height=\"117\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-03-1024x117.jpg\" alt=\"Find Docker\u2019s container name by Its ID.\" class=\"wp-image-126543\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-03-1024x117.jpg 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-03-380x43.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-03-768x87.jpg 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-03.jpg 1115w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Find Docker\u2019s container name by Its ID.<\/figcaption><\/figure>\n\n\n\n<p>We&#8217;ve confirmed that the Docker container responsible for the log file is named &#8220;<em>php-fpm-valente<\/em>&#8221; in our case.<\/p>\n\n\n\n<p>To double-check that this is the correct container that produced the log file, you can verify this by using the <code>docker inspect &lt;container_name><\/code> command to get more details about it and confirm that it&#8217;s the source of the log file. In our case, it would look like this:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">docker inspect php-fpm-valente<\/code><\/span><\/pre>\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-04.jpg\"><img decoding=\"async\" width=\"1024\" height=\"473\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-04-1024x473.jpg\" alt=\"Get detailed information about the container.\" class=\"wp-image-126552\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-04-1024x473.jpg 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-04-380x175.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-04-768x355.jpg 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-04.jpg 1152w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Get detailed information about the container.<\/figcaption><\/figure>\n\n\n\n<p>Or use the command below to get only the path information to the log file.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">docker inspect --format=<span class=\"hljs-string\">'{{.LogPath}}'<\/span> &lt;container_name&gt;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-07.jpg\"><img decoding=\"async\" width=\"1024\" height=\"106\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-07-1024x106.jpg\" alt=\"Get the full path to the log file of a specific Docker container.\" class=\"wp-image-126645\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-07-1024x106.jpg 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-07-380x39.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-07-768x79.jpg 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-07.jpg 1076w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Get the full path to the log file of a specific Docker container.<\/figcaption><\/figure>\n\n\n\n<p>Now that we have all the data we need, let me show you how to clear the contents of the corresponding log file to free up disk space.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Cleaning Docker Container Logs<\/h2>\n\n\n\n<p>You can use the <code>truncate<\/code> command to clear all the contents of an individual log file. Just provide the full path to the log file you want to clear as a parameter. For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">truncate -s <span class=\"hljs-number\">0<\/span> \/<span class=\"hljs-keyword\">var<\/span>\/lib\/docker\/containers\/d2e9228f92b66ac09fa35dcab36abba2eb4a7f46baa1d03b65d71ed8d42de977\/d2e9228f92b66ac09fa35dcab36abba2eb4a7f46baa1d03b65d71ed8d42de977-json.log<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-05.jpg\"><img decoding=\"async\" width=\"1024\" height=\"288\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-05-1024x288.jpg\" alt=\"Clearing all the contents of a single Docker log file. \" class=\"wp-image-126564\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-05-1024x288.jpg 1024w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-05-380x107.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-05-768x216.jpg 768w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-05.jpg 1081w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Clearing all the contents of a single Docker log file.<\/figcaption><\/figure>\n\n\n\n<p>If you choose a more aggressive approach, you can clear all Docker log files with just one command. But be sure you understand what you&#8217;re doing before you run the command below.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">truncate -s 0 \/var\/lib\/docker\/containers\/*\/*-json.log<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Setting Up Docker Log Size Limits<\/h2>\n\n\n\n<p>The approach described above offers a temporary fix for managing large Docker log files and freeing up disk space. However, it requires regular use of certain commands, which might be inconvenient.<\/p>\n\n\n\n<p>A way better and more permanent solution would be to limit the maximum size of Docker log files. Once this size is reached, the Docker daemon will automatically rotate those log files and archive them following naming conventions such as &#8220;<em>&lt;container_id&gt;-json.log.1<\/em>,&#8221; &#8220;<em>&lt;container_id&gt;-json.log.2<\/em>,&#8221; etc., depending on the options shown below.<\/p>\n\n\n\n<p>This guarantees that the log files do not grow uncontrollably. Here&#8217;s how to do it.<\/p>\n\n\n\n<p>To apply log rotation settings globally to all containers run by the Docker daemon, you can edit the Docker daemon configuration file, typically located at &#8220;<em>\/etc\/docker\/daemon.json<\/em>.&#8221; If the file does not exist, you can create it by executing a command similar to:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">sudo nano \/etc\/docker\/daemon.json<\/code><\/span><\/pre>\n\n\n<p><br>Then, paste the following content into the file, save it and exit:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JSON \/ JSON with Comments\" data-shcb-language-slug=\"json\"><span><code class=\"hljs language-json\">{\n  <span class=\"hljs-attr\">\"log-driver\"<\/span>: <span class=\"hljs-string\">\"json-file\"<\/span>,\n  <span class=\"hljs-attr\">\"log-opts\"<\/span>: {\n    <span class=\"hljs-attr\">\"max-size\"<\/span>: <span class=\"hljs-string\">\"10m\"<\/span>,\n    <span class=\"hljs-attr\">\"max-file\"<\/span>: <span class=\"hljs-string\">\"3\"<\/span>\n  }\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JSON \/ JSON with Comments<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">json<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Okay, let me explain what this does. In short, it sets the log driver to &#8220;<em>json-file<\/em>,&#8221; setting the maximum allowed size of a single Docker log file to 10 megabytes and allowing up to 3 versions of the file to be archived.<\/p>\n\n\n\n<p>Next, to apply the changes, simply restart the Docker service:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">sudo systemctl restart docker<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It&#8217;s important to remember that <strong>these changes will only affect newly created Docker containers, not the ones already running<\/strong>. To apply the changes to existing ones, you must first delete them and then create them again. Here&#8217;s how you can do it.<\/p>\n\n\n\n<p>If you started the containers using a standard Docker command, use this to stop and then remove a container in one command:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">docker rm -f &lt;container_id_or_name&gt;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This is a handy command to stop and remove a container immediately. However, using &#8220;<em>-f<\/em>&#8221; might be risky as it does not allow a clean shutdown of applications running in the container. Then just run it again like you did before.<\/p>\n\n\n\n<p>If you&#8217;re using Docker Compose, just navigate to the folder with the &#8220;<em>docker-compose.yml<\/em>&#8221; file and run the following command:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">docker compose down<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It stops and removes all the resources defined in the file. Then, rerun the deployment:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"Bash\" data-shcb-language-slug=\"bash\"><span><code class=\"hljs language-bash\">docker compose up -d<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Bash<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">bash<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If you look at the container details again, you should see that the data you previously entered in the Docker &#8220;<em>daemon.json<\/em>&#8221; file has been applied to the container.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\">docker inspect <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">container_name<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-06.jpg\"><img decoding=\"async\" width=\"954\" height=\"370\" src=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-06.jpg\" alt=\"Get detailed information about the container.\" class=\"wp-image-126609\" srcset=\"https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-06.jpg 954w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-06-380x147.jpg 380w, https:\/\/linuxiac.com\/wp-content\/uploads\/2024\/07\/docker-log-size-06-768x298.jpg 768w\" sizes=\"(max-width: 954px) 100vw, 954px\" \/><\/a><figcaption class=\"wp-element-caption\">Get detailed information about the container.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Managing Docker log sizes is essential to maintaining an efficient and sustainable server environment.<\/p>\n\n\n\n<p>This guide provides a strategy for managing the size of Docker log files and ensuring that logs do not accumulate uncontrollably using Docker&#8217;s log rotation and cleanup capabilities.<\/p>\n\n\n\n<p>Ultimately, applying these practices allows for better resource management and operational efficiency in a Dockerized environment.<\/p>\n\n\n\n<p>Refer to the <a href=\"https:\/\/docs.docker.com\/config\/daemon\/\" target=\"_blank\" rel=\"noreferrer noopener\">official documentation<\/a> for more detailed information on configuring Docker using the \u201c<em>daemon.json<\/em>\u201d&nbsp;file. We also recommend checking out our guide, especially <a href=\"https:\/\/linuxiac.com\/docker-logs\/\" target=\"_blank\" rel=\"noreferrer noopener\">dedicated to Docker log files<\/a>.<\/p>\n\n\n\n<p>Thanks for using our guide! Feel free to share your thoughts in the comments section below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Struggling with big Docker logs? Our guide shows you how to find, reduce, and manage them to save disk space effectively.<\/p>\n","protected":false},"author":10,"featured_media":126336,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,4417],"tags":[1439,4203],"class_list":["post-126333","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips","category-linux-knowledge","tag-docker","tag-logs"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/posts\/126333","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/comments?post=126333"}],"version-history":[{"count":0,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/posts\/126333\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/media\/126336"}],"wp:attachment":[{"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/media?parent=126333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/categories?post=126333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxiac.com\/wp-json\/wp\/v2\/tags?post=126333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}