<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: bongo</title>
    <description>The latest articles on DEV Community by bongo (@bong0).</description>
    <link>https://dev.to/bong0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F124341%2F0d80e7f9-1784-4d5f-9ac6-4034253f4775.png</url>
      <title>DEV Community: bongo</title>
      <link>https://dev.to/bong0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bong0"/>
    <language>en</language>
    <item>
      <title>Limiting docker container's log size in CoreOS (running, but not limited to XenServer 7)</title>
      <dc:creator>bongo</dc:creator>
      <pubDate>Thu, 27 Dec 2018 21:46:59 +0000</pubDate>
      <link>https://dev.to/bong0/limiting-docker-containers-log-size-in-coreos-running-but-not-limited-to-xenserver-7-3gjo</link>
      <guid>https://dev.to/bong0/limiting-docker-containers-log-size-in-coreos-running-but-not-limited-to-xenserver-7-3gjo</guid>
      <description>

&lt;p&gt;I had a problem: my gitlab docker container generated &amp;gt;6GiB of json-log (&lt;code&gt;/var/lib/docker/containers/&amp;lt;ID&amp;gt;/*.json&lt;/code&gt;) filling up my disk. &lt;/p&gt;

&lt;p&gt;I'm running CoreOS within a Citrix XenServer 7 with the Container Management Supplement Pack installed.&lt;/p&gt;

&lt;p&gt;The way of configuring the Coreos VM is via /Cloud-Config/. There are multiple ways of configuring the docker service within CoreOS to set some global logging-driver options.&lt;/p&gt;

&lt;p&gt;CoreOS' default driver is &lt;strong&gt;json-file&lt;/strong&gt; with no limits. (as of dec. 2018)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shutdown the CoreOS VM&lt;/li&gt;
&lt;li&gt;Within XenCenter, edit the Cloudconfig as follows:
To set up log-file limits to e.g. Maximum 60MiB/container and 1 logfile per container, insert below the &lt;em&gt;write_files&lt;/em&gt; section:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;write_files:
  - path: "/etc/docker/daemon.json"
    permissions: "0644"
    owner: "root"
    content: |
      {
        "log-driver": "json-file",
        "log-opts": {
          "max-size": "60m",
          "max-file": "1"
        }
      }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Start the VM again&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;IMPORTANT&lt;/strong&gt;: Changes to this global setting are &lt;strong&gt;ONLY applied to newly created containers&lt;/strong&gt;, so you'll need to re-setup every container you want to apply the setting to. If you don't, editing the &lt;code&gt;hostconfig.json&lt;/code&gt; will not help, it's getting overwritten upon container restart.&lt;/p&gt;




&lt;p&gt;Optional:&lt;/p&gt;

&lt;p&gt;Verify file write worked:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat /etc/docker/daemon.json
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "60m",
    "max-file": "1"
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Verify container has applied the log settings (as root):&lt;br&gt;
&lt;em&gt;/var/lib/docker/containers//hostconfig.json&lt;/em&gt;&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"Binds":["/srv/gitlab/config:/etc/gitlab","/srv/gitlab/logs:/var/log/gitlab","/srv/gitlab/data:/var/opt/gitlab"],
"ContainerIDFile":"",
"LogConfig":{"Type":"json-file","Config":{"max-file":"1","max-size":"60m"}},
"NetworkMode":"public".....
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;See the IMPORTANT notice above, if this doesn't reflect the hostconfig you're seeing, regardig the &lt;strong&gt;LogConfig&lt;/strong&gt; section. &lt;/p&gt;


</description>
      <category>docker</category>
      <category>coreos</category>
      <category>xenserver</category>
      <category>containermanagement</category>
    </item>
  </channel>
</rss>
