<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Peek Read Info (Posts about docker)</title><link>https://peekread.info/</link><description></description><atom:link href="https://peekread.info/tags/docker.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2024 &lt;a href="mailto:dugite-code@peekread.info"&gt;Dugite-Code&lt;/a&gt; 
&lt;a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"&gt;
&lt;img alt="Creative Commons License BY-SA"
width="88px" height="31px" style="border-width:0; margin-bottom:12px;"
src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png"&gt;&lt;/a&gt;</copyright><lastBuildDate>Wed, 14 Feb 2024 06:33:10 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Docker Volume Backups</title><link>https://peekread.info/tech/20200220-docker-volume-backups/</link><dc:creator>Dugite-Code</dc:creator><description>&lt;p&gt;&lt;/p&gt;&lt;div class="d-flex position-relative pt-3 pb-3"&gt;
    &lt;div class="flex-shrink-0 me-3"&gt;
        &lt;img data-pagefind-meta="image[src], image_alt[alt]" style="height:89px;" src="https://peekread.info/images/services/docker.png" alt=""&gt;
    &lt;/div&gt;
    &lt;div&gt;
        &lt;p class="mt-3"&gt;&lt;/p&gt;&lt;p&gt;Backups are always an issue. I plan to switch to ZFS for the snapshotting and remote sync features, until then I have take the useful &lt;a href="https://github.com/loomchild/volume-backup"&gt;volume-backup&lt;/a&gt; and broken it until it works with &lt;a href="https://rdiff-backup.net/"&gt;rdiff-backup&lt;/a&gt;&lt;/p&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;Build the container&lt;/h4&gt;
&lt;p&gt;First you have to clone the repo and build the container&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;git&lt;span class="w"&gt; &lt;/span&gt;clone&lt;span class="w"&gt; &lt;/span&gt;https://github.com/dugite-code/volume-backup.git
&lt;span class="nb"&gt;cd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;volume-backup
docker&lt;span class="w"&gt; &lt;/span&gt;image&lt;span class="w"&gt; &lt;/span&gt;build&lt;span class="w"&gt; &lt;/span&gt;-t&lt;span class="w"&gt; &lt;/span&gt;vbackup:1.0&lt;span class="w"&gt; &lt;/span&gt;.
&lt;/pre&gt;&lt;/div&gt;

&lt;h4&gt;Backup&lt;/h4&gt;
&lt;p&gt;Now you can run the container mounting the &lt;code&gt;[volume-name]&lt;/code&gt; at &lt;code&gt;/volume&lt;/code&gt; and your &lt;code&gt;[backup-dir]&lt;/code&gt; at &lt;code&gt;/backup&lt;/code&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;docker&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;-v&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;volume-name&lt;span class="o"&gt;]&lt;/span&gt;:/volume&lt;span class="w"&gt; &lt;/span&gt;-v&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;backup-dir&lt;span class="o"&gt;]&lt;/span&gt;:/backup&lt;span class="w"&gt; &lt;/span&gt;--rm&lt;span class="w"&gt; &lt;/span&gt;vbackup:1.0&lt;span class="w"&gt; &lt;/span&gt;backup
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Additional rdiff-backup options and be passed via the &lt;code&gt;-o&lt;/code&gt; switch and a quoted option for example &lt;code&gt;-o "--exclude ignore.me"&lt;/code&gt;&lt;/p&gt;
&lt;h3&gt;Restore&lt;/h3&gt;
&lt;p&gt;To restore you &lt;strong&gt;must&lt;/strong&gt; supply some form of options i.e. &lt;code&gt;-o "-r 10D"&lt;/code&gt; or restore backup from 10 Days ago&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;docker&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;-v&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;volume-name&lt;span class="o"&gt;]&lt;/span&gt;:/volume&lt;span class="w"&gt; &lt;/span&gt;-v&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;backup-dir&lt;span class="o"&gt;]&lt;/span&gt;:/backup&lt;span class="w"&gt; &lt;/span&gt;--rm&lt;span class="w"&gt; &lt;/span&gt;vbackup:1.0&lt;span class="w"&gt; &lt;/span&gt;restore&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"-r 10D"&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Trimming old files&lt;/h3&gt;
&lt;p&gt;With incremental backups it's important to occasionally trim old files that just don't exist anymore. Like Restore you &lt;strong&gt;must&lt;/strong&gt; provide some form of option.&lt;/p&gt;
&lt;p&gt;Prior to doing a backup I will run this command to remove files older than 20 Backups&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;docker&lt;span class="w"&gt; &lt;/span&gt;run&lt;span class="w"&gt; &lt;/span&gt;-v&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;backup-dir&lt;span class="o"&gt;]&lt;/span&gt;:/backup&lt;span class="w"&gt; &lt;/span&gt;--rm&lt;span class="w"&gt; &lt;/span&gt;vbackup:1.0&lt;span class="w"&gt; &lt;/span&gt;remote&lt;span class="w"&gt; &lt;/span&gt;-v&lt;span class="w"&gt; &lt;/span&gt;-o&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"--remove-older-than 20B"&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;I hope you found this helpful. It's not a very clean script, I had to hack apart the reference script quite a bit in order to get it all working. But it serves it's purpose quite well.&lt;/p&gt;</description><category>backups</category><category>docker</category><guid>https://peekread.info/tech/20200220-docker-volume-backups/</guid><pubDate>Wed, 19 Feb 2020 16:00:00 GMT</pubDate></item><item><title>I am a Docker Convert</title><link>https://peekread.info/tech/20200121-i-am-a-docker-convert/</link><dc:creator>Dugite-Code</dc:creator><description>&lt;p&gt;&lt;/p&gt;&lt;div class="d-flex position-relative pt-3 pb-3"&gt;
    &lt;div class="flex-shrink-0 me-3"&gt;
        &lt;img data-pagefind-meta="image[src], image_alt[alt]" style="height:89px;" src="https://peekread.info/images/services/docker.png" alt=""&gt;
    &lt;/div&gt;
    &lt;div&gt;
        &lt;p class="mt-3"&gt;&lt;/p&gt;&lt;p&gt;I've changed my mind quite a bit when it comes to docker. I used to be a big believer in virtual machines, I still am, but for individual 'applications' Docker makes a fair bit of sense.&lt;/p&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;h2&gt;Reasons to I use Docker&lt;/h2&gt;
&lt;h3&gt;Simplicity&lt;/h3&gt;
&lt;p&gt;Docker is the simplest way to replicate a developer's environment on your own computer. No more dealing with differing distro's varying update cycles and the conflicting packages causing edge case issues, because everything is in it's own little box. Nice and predictable.&lt;/p&gt;
&lt;p&gt;This saves you time setting things up because at least all the components are included. Configuration is still a pain on some projects, but at least your not missing any metaphorical screws.&lt;/p&gt;
&lt;p&gt;The biggest example for this was my mailserver. I used &lt;a href="https://github.com/modoboa/modoboa/"&gt;modoboa&lt;/a&gt; a great simple mailserver package. The issues were having things brake from system package updates and just updating the package itself was damned complicated. I learnt a lot from these breakages, so much so when I switched to docker I switched to using &lt;a href="https://github.com/tomav/docker-mailserver"&gt;docker-mailserver&lt;/a&gt; a image that has no Web GUI for configuration.&lt;/p&gt;
&lt;p&gt;Updates, while problematic to monitor in docker are now a simple painless affair.&lt;/p&gt;
&lt;h3&gt;Lightweight&lt;/h3&gt;
&lt;p&gt;Unlike a virtual machine you don't need to replicate &lt;strong&gt;everything&lt;/strong&gt; in a container. This makes it easier to have more services that conflict with each other running side by side. I used to have one &lt;a href="https://en.wikipedia.org/wiki/Next_Unit_of_Computing" title="Next Unit of Computing (NUC) is a line of small-form-factor barebone computer kits designed by Intel."&gt;dedicated NUC&lt;/a&gt; for my mailserver and another for all my other services. I've now condensed it all onto the single NUC with better overall performance thanks to docker.&lt;/p&gt;
&lt;h3&gt;Portability&lt;/h3&gt;
&lt;p&gt;One of the biggest advantages to docker is portability. If you take your raw data and docker-compose files throw them onto a completely separate machine and within a few minutes you are up and running again. For virtual machines this would take significant work and, in my experience often fails.&lt;/p&gt;
&lt;h2&gt;The Issues I have with docker&lt;/h2&gt;
&lt;h3&gt;The pre-built images&lt;/h3&gt;
&lt;p&gt;The &lt;a href="https://www.zdnet.com/article/alpine-linux-docker-images-ship-a-root-account-with-no-password/"&gt;Alpine image root issue&lt;/a&gt; last year, where the base image used to build a large number of docker images shipped with a vulnerability, made it obvious you need an actively maintained update cycle.&lt;/p&gt;
&lt;p&gt;If the project you are using doesn't provide a docker image or even a dockerfile you will often find pre-built images on docker-hub. The big question you need to ask is if you can trust these images. Check the source repository and decide if it would make more sense to build the image yourself.&lt;/p&gt;
&lt;h3&gt;Keeping pre-built images up-to date&lt;/h3&gt;
&lt;p&gt;One of the biggest issues people have with docker is the lack of update tracking. Thankfully this can be overcome using the &lt;a href="https://github.com/containrrr/watchtower"&gt;Watchtower&lt;/a&gt; image.&lt;/p&gt;
&lt;p&gt;I set watchtower to monitor only mode because automatic updates are &lt;a href="https://fedoraproject.org/wiki/AutoUpdates#Reasons_AGAINST_using_automatic_updates" title="While no one can determine for you if your machine is a bad candidate for automatic updates, there are several things which tend to make a machine a worse candidate for automatic updates."&gt;sometimes a terrible idea&lt;/a&gt;.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="nt"&gt;watchtower&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;containrrr/watchtower&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;container_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;watchtower&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;/var/run/docker.sock:/var/run/docker.sock&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;restart&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;unless-stopped&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nt"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;WATCHTOWER_POLL_INTERVAL=86400&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;#Poll every 24 hours&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;WATCHTOWER_MONITOR_ONLY=true&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;WATCHTOWER_NOTIFICATIONS=gotify&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;WATCHTOWER_NOTIFICATION_GOTIFY_URL=https://example.tld/gotify/&lt;/span&gt;
&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;WATCHTOWER_NOTIFICATION_GOTIFY_TOKEN=###########&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Importantly for locally built images add the disable label to their docker-compose files, or you will constantly get notifications saying &lt;code&gt;(info): Unable to update container /examplecontainer. Proceeding to next.&lt;/code&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;labels&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p p-Indicator"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="l l-Scalar l-Scalar-Plain"&gt;com.centurylinklabs.watchtower.enable=false&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;</description><category>docker</category><category>selfhost</category><guid>https://peekread.info/tech/20200121-i-am-a-docker-convert/</guid><pubDate>Mon, 20 Jan 2020 16:00:00 GMT</pubDate></item></channel></rss>