<?xml version="1.0" encoding="utf-8" standalone="yes"?><?xml-stylesheet href="/rss.xsl" type="text/xsl" ?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Docker-Registry | Bacardi55&#39;s Web Cave</title>
    <link>https://bacardi55.io/tags/docker-registry/</link>
    <description>Recent content in Docker-Registry on Bacardi55&#39;s Web Cave</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>bac@rdi55.pl (bacardi55)</managingEditor>
    <webMaster>bac@rdi55.pl (bacardi55)</webMaster>
    <copyright>2010-2025 bacardi55</copyright>
    <lastBuildDate>Sun, 04 Apr 2021 00:00:00 +0200</lastBuildDate>
    <atom:link href="https://bacardi55.io/tags/docker-registry/index.xml" rel="self" type="application/rss+xml" />
    <item>
      
      <title>Moving gmnisrv to my swarm cluster</title><link>https://bacardi55.io/2021/04/04/moving-gmnisrv-to-my-swarm-cluster/</link><pubDate>Sun, 04 Apr 2021 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2021/04/04/moving-gmnisrv-to-my-swarm-cluster/</guid><description>&lt;h2 id=&#34;context&#34;&gt;Context&lt;/h2&gt;&#xA;&lt;p&gt;Based on my previous post about&#xA;&lt;a href=&#34;https://bacardi55.io/2021/03/29/home-lab-part-8-create-a-local-docker-registry-to-manage-your-own-images/&#34;&gt;managing&#xA;a local docker registry&lt;/a&gt;, as promised let&amp;rsquo;s use it to create a useful&#xA;image and deploy it on &lt;a href=&#34;https://bacardi55.io/pages/home-lab/&#34;&gt;my swarm&#xA;cluster homelab&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;For this example, I&amp;rsquo;ve decided to use the latest image I&amp;rsquo;ve created:&#xA;&lt;a href=&#34;https://git.sr.ht/~sircmpwn/gmnisrv&#34;&gt;gmnisrv&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Wait what? Gmnisrv running on a docker swarm? Why??&lt;/p&gt;&#xA;&lt;p&gt;There are no real good reason to have the gemini server as a docker&#xA;service&amp;hellip; So why? Well the real reasons? Because: - I can :p; - I have&#xA;this docker swarm working very smoothly, so let&amp;rsquo;s use it; - I could have&#xA;just installed it directly on one of the node, but that made not much&#xA;sens; - I can manage it as all the other services^^.&lt;/p&gt;&#xA;&lt;p&gt;Last week, I made the change from the local installation on a test pi to&#xA;the cluster, smoothly from what I&amp;rsquo;ve seen, without certificate change.&#xA;But that&amp;rsquo;s not the point of this article^^ (and TBH, I failed&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt; the&#xA;weekend before :D).&lt;/p&gt;&#xA;&lt;h2 id=&#34;installation&#34;&gt;Installation&lt;/h2&gt;&#xA;&lt;h3 id=&#34;creating-the-image-for-the-cluster&#34;&gt;Creating the image for the cluster&lt;/h3&gt;&#xA;&lt;p&gt;So first thing first, we need to create the image on the registry before&#xA;being able to use it on the cluster. Feel free to refer to my post about&#xA;&lt;a href=&#34;https://bacardi55.io/2021/03/29/home-lab-part-8-create-a-local-docker-registry-to-manage-your-own-images/&#34;&gt;managing&#xA;a local docker registry&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;On the registry (in my case named &lt;code&gt;freeza&lt;/code&gt;), let&amp;rsquo;s create the image.&#xA;Let&amp;rsquo;s create a working directory:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir ~/dockerfiles/gmnisrv &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; cd ~/dockerfiles/gmnisrv&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, create the very simple &lt;code&gt;Dockerfile&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    FROM alpine:3.12&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    RUN apk add --no-cache git make scdoc openssl-dev build-base mailcap &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        cd /tmp &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        git clone https://git.sr.ht/~sircmpwn/gmnisrv &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        cd gmnisrv &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        mkdir build &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        cd build &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        ../configure --prefix&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;/usr &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        make &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;&lt;/span&gt;        make install&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    VOLUME /certs&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    VOLUME /config&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    VOLUME /data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    CMD &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;gmnisrv&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;-C&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/config/gmnisrv.ini&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Very simple :-).&lt;/p&gt;&#xA;&lt;p&gt;Then, let&amp;rsquo;s try and build the image:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker build .&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If this works correctly, you can tag the image (I always prefix their&#xA;name with &lt;code&gt;b55-&lt;/code&gt;):&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker build . -t registry.local:5000/b55-gmnisrv:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Adapt with your registry hostname and port.&lt;/p&gt;&#xA;&lt;p&gt;Push the image to the directory:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker push registry.local:5000/b55-gmnisrv:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To test the image, you can either use &lt;code&gt;docker run&lt;/code&gt; or &lt;code&gt;docker-compose&lt;/code&gt;.&#xA;Because I&amp;rsquo;m will use a docker-compose file on my cluster, I prefer&#xA;testing it with a docker-compose file, buit this doesn&amp;rsquo;t matter.&lt;/p&gt;&#xA;&lt;p&gt;In my case, the local docker-compose.yml file is:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#39;3&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      gmnisrv:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: registry.local:5000/b55-gmnisrv:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - 1965:1965&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/testdir/gmnisrv/data/:/data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/testdir/gmnisrv/config/:/config&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/testdir/gmnisrv/certs:/certs&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then the usual &lt;code&gt;docker-compose up&lt;/code&gt; to see if this works correctly (be&#xA;sure to create the volumes if you want to try with it).&lt;/p&gt;&#xA;&lt;p&gt;If you want to run a full test before deploying on your cluster, you can&#xA;create a simple .gmi file in the &lt;em&gt;data&lt;/em&gt; directory, create a dev host in&#xA;the gmnisrv config file (and edit your host file).&lt;/p&gt;&#xA;&lt;h3 id=&#34;deploying-it-to-the-cluster&#34;&gt;Deploying it to the cluster&lt;/h3&gt;&#xA;&lt;p&gt;If everything work, we can use it on the cluster. Adapt a bit the docker&#xA;file to have:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#39;3&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      server:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: registry.local:5000/b55-gmnisrv:latest&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - &amp;#34;1965:1965&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        deploy:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          placement:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            constraints:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;              - node.hostname == ptitcell2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/containers-data/gmnisrv/data/:/data&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/containers-data/gmnisrv/certs/:/certs&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - /path/to/services-config/gmnisrv/config/:/config&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Main difference the placement constraints to a specific node of the&#xA;cluster. I could have use &lt;a href=&#34;https://traefik.io/traefik/&#34;&gt;traefik&lt;/a&gt; for&#xA;load balancing the entry like I do for all services&amp;hellip; But I didn&amp;rsquo;t^^. I&#xA;didn&amp;rsquo;t see the point of adding load to traefik and the node manager for&#xA;gmnisrv that works on a port that will only be used by gmnisrv. Gmnisrv&#xA;support multi hosts anyway if I want to add capsules in the future (I&amp;rsquo;m&#xA;planing to have a feed type of capsule).&lt;/p&gt;&#xA;&lt;p&gt;So, long story short, I force the container to only work on the&#xA;&lt;code&gt;ptitcell2&lt;/code&gt; node. And I forward the 1965 port on my router to the&#xA;&lt;code&gt;ptitcell2&lt;/code&gt; node. I thus save a bit on the manager.&lt;/p&gt;&#xA;&lt;p&gt;If you don&amp;rsquo;t care by recreating new certs (if your capsule wasn&amp;rsquo;t live&#xA;yet), you can just start it like this, otherwise just copy/paste the&#xA;certificates in the right folder before starting the stack with&#xA;&lt;code&gt;docker stack deploy gmnisrv -c /path/to/services-config/gmnisrv/docker-compose.yml&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And voilà :] Granted that I have close to no reader on my capsule, I can&#xA;still say it has worked perfectly since then!&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;In reality I failed for multiple reasons, but also discovered a&#xA;bug in the latest version of gmnisrv. I fixed it with the help of&#xA;&lt;a href=&#34;https://drewdevault.com&#34;&gt;Drew Devault&lt;/a&gt;. Since then my patch&#xA;has been accepted so even if what I wrote was the&#xA;&lt;a href=&#34;https://git.sr.ht/~sircmpwn/gmnisrv/commit/8b65e303b01fc573cb1c40a365fb5db166146a37&#34;&gt;simplest&#xA;patch&lt;/a&gt; in the history of patch, I&amp;rsquo;m still happy about it^^.&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
    <item>
      
      <title>Home Lab part 8: Create a local docker registry to manage your own images</title><link>https://bacardi55.io/2021/03/29/home-lab-part-8-create-a-local-docker-registry-to-manage-your-own-images/</link><pubDate>Mon, 29 Mar 2021 00:00:00 +0200</pubDate><author>bac@rdi55.pl (bacardi55)</author><guid>https://bacardi55.io/2021/03/29/home-lab-part-8-create-a-local-docker-registry-to-manage-your-own-images/</guid><description>&lt;h2 id=&#34;why-a-local-registry&#34;&gt;Why a local registry?&lt;/h2&gt;&#xA;&lt;p&gt;This is a good question and there are many answers to this. But for me&#xA;the main reasons is that I like be &amp;ldquo;in control&amp;rdquo; of some of the&#xA;containers I&amp;rsquo;m running. I don&amp;rsquo;t create my own images for everything at&#xA;all, but I do use a mix of both. For very well known applications like&#xA;traefik, nginx, mariadb, postgresql, &amp;hellip; I usually use public images.&#xA;Sometimes, for specific services/applications I either don&amp;rsquo;t find an&#xA;offical arm images (Needed for rpi), or sometimes I may not like how&#xA;these official images are built.&lt;/p&gt;&#xA;&lt;p&gt;As I said many times in previous post, you should always be very aware&#xA;of how the containers you use are built and configured. And when in&#xA;doubt or need, build your own and keep the whole thing under control&#xA;:-). I use only public images in my posts mainly for simplicity (and&#xA;because I don&amp;rsquo;t publish my images outside my private registry).&lt;/p&gt;&#xA;&lt;p&gt;In this post, I&amp;rsquo;ll explain how to setup a registry on my local network&#xA;for reuse on my cluster. In the next one, I&amp;rsquo;ll show a real use case I&amp;rsquo;m&#xA;using. In a later post, I&amp;rsquo;ll talk about automation around image&#xA;creation.&lt;/p&gt;&#xA;&lt;h2 id=&#34;creating-a-local-docker-registry&#34;&gt;Creating a local docker registry&lt;/h2&gt;&#xA;&lt;h3 id=&#34;my-choices&#34;&gt;My choices&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Only available on my local network, which is why:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I won&amp;rsquo;t add (for now at least) HTTP authentication;&lt;/li&gt;&#xA;&lt;li&gt;I use a self-signed certificate (and not letsencrypt or others);&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Setup on a dedicated &amp;ldquo;non prod&amp;rdquo; raspberry pi (named &lt;code&gt;freeza&lt;/code&gt;&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;);&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;Only ARM containers (not multi architecture&amp;hellip; yet).&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;strong&gt;Assumptions&lt;/strong&gt;: This article assume you already have a server setup with&#xA;docker installed. And in my case, on a rpi not in the swarm cluster.&lt;/p&gt;&#xA;&lt;h3 id=&#34;creating-the-registry&#34;&gt;Creating the registry&lt;/h3&gt;&#xA;&lt;p&gt;First, add your domain to &lt;code&gt;/etc/host&lt;/code&gt; if you are using a fake domain&#xA;(and no local dns server). In this example, I&amp;rsquo;m using &lt;code&gt;registry.local&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then create the working directory, here I named it &lt;code&gt;docker-registry&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir docker-registry &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; cd docker-registry&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Create the &lt;code&gt;docker-compose.yml&lt;/code&gt; file:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: &amp;#39;3&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    services:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      registry55:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        restart: always&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        image: registry:2&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        ports:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - &amp;#34;5000:5000&amp;#34; # ChangeMe&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        environment:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - REGISTRY_HTTP_TLS_CERTIFICATE=/certs/registry.local.crt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - REGISTRY_HTTP_TLS_KEY=/certs/registry.local.key&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        volumes:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - ./registry:/var/lib/registry&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - ./registry-config/config.yml:/etc/docker/registry/config.yml&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - ./certs:/certs&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        networks:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;          - registry-ui-net&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Configure the registry by creating the &lt;code&gt;registry-config/config.yml&lt;/code&gt;&#xA;file:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    version: 0.1&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    log:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      fields:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        service: registry&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    storage:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      delete:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        enabled: true&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      cache:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        blobdescriptor: inmemory&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      filesystem:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        rootdirectory: /var/lib/registry&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    http:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      addr: :5000 # ChangeMe&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      headers:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        X-Content-Type-Options: [nosniff]&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Changed the port if you wish.&lt;/p&gt;&#xA;&lt;p&gt;Then, create the directory for the certiticats and the registry:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;certs,registry&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For other servers to leverage your local registry, it needs to work via&#xA;HTTPS, so we need to create the certificate:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/registry.local.key -x509 -days &lt;span style=&#34;color:#ae81ff&#34;&gt;365&lt;/span&gt; -out certs/registry.local.crt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For the FQDN, use the domain set above in the &lt;code&gt;docker-compose.yml&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h4 id=&#34;testing&#34;&gt;Testing&lt;/h4&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s test with a simple alpine image. We&amp;rsquo;ll see in the next post a real&#xA;use case.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker pull alpine:3.13&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let&amp;rsquo;s tag the image now. When the first part of the tag is a hostname&#xA;and port, Docker interprets this as the location of a registry, when&#xA;pushing.&lt;/p&gt;&#xA;&lt;p&gt;For my local images, I always start their name with &lt;code&gt;b55-&lt;/code&gt;, but this is&#xA;just my own convention :).&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker tag alpine:3.13 registry.local:5000/b55-alpine-313&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Push the image to the local registry running at &lt;code&gt;registry.local:5000&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker push registry.local:5000/b55-alpine-313&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Remove the locally-cached alpine image, so that you can test pulling the&#xA;image from your registry. This does not remove the registry.local:5000/&#xA;image from your registry.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker image remove alpine:3.13&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker image remove registry.local:5000/b55-alpine-313&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then pull the image from the registry to see if it&amp;rsquo;s working.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker pull registry.local:5000/b55-alpine-313&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It should pull the image :).&lt;/p&gt;&#xA;&lt;h3 id=&#34;using-images-from-the-local-registry-on-others-servers&#34;&gt;Using images from the local registry on others servers&lt;/h3&gt;&#xA;&lt;p&gt;Now, to pull images from the registry on others servers, we will need to&#xA;add the certificate to these servers. This is because we are using a&#xA;self-signed certificate. But to be honest, for a local service, I don&amp;rsquo;t&#xA;see the point of the hassle of getting one from letsencrypt or others.&lt;/p&gt;&#xA;&lt;p&gt;We just need to add the certificate to the docker configuration.&lt;/p&gt;&#xA;&lt;p&gt;To do so, copy the created crt file above to the other servers that will&#xA;need it (via &lt;code&gt;scp&lt;/code&gt; for example). Place the file in&#xA;&lt;code&gt;/etc/docker/certs.d/registry.local:5000&lt;/code&gt;. Adapt with the right hostname&#xA;and ports.&lt;/p&gt;&#xA;&lt;p&gt;Be Careful, the files needs to be named &lt;code&gt;ca.crt&lt;/code&gt;!&lt;/p&gt;&#xA;&lt;p&gt;You may need to create the &lt;code&gt;certs.d&lt;/code&gt; directory if it doesn&amp;rsquo;t exist yet.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    mkdir -p /etc/docker/certs.d/registry.local:5000&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    scp user@server:/path/to/registry.local.crt /etc/docker/certs.d/registry.local:5000/ca.crt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You now need to restart docker:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    sudo systemctl restart docker.service&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Nota&lt;/strong&gt;: You need to add the certificate to all your docker swarm nodes.&#xA;As any of the nodes could need to pull one of the local registry&#xA;images&lt;sup id=&#34;fnref:2&#34;&gt;&lt;a href=&#34;#fn:2&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then, you can try pulling the image, with as usual:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-sh&#34; data-lang=&#34;sh&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    docker pull registry.local:5000/b55-alpine-313&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And it should pull the image :).&lt;/p&gt;&#xA;&lt;h3 id=&#34;registry-ui&#34;&gt;Registry UI?&lt;/h3&gt;&#xA;&lt;p&gt;There are many docker registry web UI available. Seems that the most&#xA;maintained and popular one is&#xA;&lt;a href=&#34;https://github.com/Joxit/docker-registry-ui&#34;&gt;Joxit&amp;rsquo;s one&lt;/a&gt;. I let you&#xA;test it because on my end I don&amp;rsquo;t care about a web UI for my registry,&#xA;and instead I prefer a CLI app:&#xA;&lt;a href=&#34;https://github.com/Joxit/docker-registry-ui&#34;&gt;reg&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Reg is very nice and light. I installed it on my laptop but I could have&#xA;installed it directly on the rpi managing the registry. I might do it to&#xA;so I always have it where the registry is. But in the meantime, the&#xA;installation was very fast. Just download the right release and make the&#xA;binary executable (and available in your &lt;code&gt;$PATH&lt;/code&gt;).&lt;/p&gt;&#xA;&lt;p&gt;Only drawback of using reg is that there is no way of ignoring TLS&#xA;validation, so when using a self-signed tls certificate like me, it&#xA;means you need to add the certificate to your system configuration. So&#xA;on the machine you are using reg, you need to add the crt file in&#xA;&lt;code&gt;/usr/share/ca-certificates/&lt;/code&gt; and then run (as root or sudo)&#xA;&lt;code&gt;update-ca-certificates&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Then a simple &lt;code&gt;reg ls registry.local:5000&lt;/code&gt; will list the available&#xA;images. &lt;code&gt;reg -h&lt;/code&gt; to see all available commands, and voilà!&lt;/p&gt;&#xA;&lt;p&gt;In the next post, I&amp;rsquo;ll show some useful example and usage on the cluster&#xA;:).&lt;/p&gt;&#xA;&lt;div class=&#34;footnotes&#34; role=&#34;doc-endnotes&#34;&gt;&#xA;&lt;hr&gt;&#xA;&lt;ol&gt;&#xA;&lt;li id=&#34;fn:1&#34;&gt;&#xA;&lt;p&gt;This is the villain before &lt;code&gt;cell&lt;/code&gt; in the manga Dragon Ball.&#xA;Because my cluster nodes are named cell (manager) and ptitcellX&#xA;(workers), I decided to named the preprod node with the name of&#xA;the previous villain&amp;hellip;&amp;#160;&lt;a href=&#34;#fnref:1&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li id=&#34;fn:2&#34;&gt;&#xA;&lt;p&gt;As always, &lt;code&gt;tmux&lt;/code&gt; and its &lt;code&gt;synchronize-panes&lt;/code&gt; is really helpful&#xA;:).&amp;#160;&lt;a href=&#34;#fnref:2&#34; class=&#34;footnote-backref&#34; role=&#34;doc-backlink&#34;&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/div&gt;&#xA;</description></item>
  </channel>
</rss>
