<?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: Brendon Otto</title>
    <description>The latest articles on DEV Community by Brendon Otto (@brendonotto).</description>
    <link>https://dev.to/brendonotto</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%2F195621%2F9133709c-1f0f-4bf7-ae51-d173370d6217.jpg</url>
      <title>DEV Community: Brendon Otto</title>
      <link>https://dev.to/brendonotto</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/brendonotto"/>
    <language>en</language>
    <item>
      <title>Host Docker Registry on a Synology NAS</title>
      <dc:creator>Brendon Otto</dc:creator>
      <pubDate>Mon, 07 Mar 2022 04:14:57 +0000</pubDate>
      <link>https://dev.to/brendonotto/host-docker-registry-on-a-synology-nas-1b6k</link>
      <guid>https://dev.to/brendonotto/host-docker-registry-on-a-synology-nas-1b6k</guid>
      <description>&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@alexcpl?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Alex Cheung&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/synology-nas?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Post originally appeared on &lt;a href="https://www.brendonotto.com/posts/docker-repo-on-synology-nas" rel="noopener noreferrer"&gt;brendonotto.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've been working on a project off and on that I wanted to host and run on my Synology NAS (I have a DS920+). The best way to host custom software on it is to run Docker images but I didn't want to push this to a public repo, I have a local server after all 😁.&lt;/p&gt;

&lt;h3&gt;
  
  
  Get Docker Repo image
&lt;/h3&gt;

&lt;p&gt;This step is pretty simple, run the Docker Repository image on your NAS. It can be found searching the registry:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhuut20noojpqoqn4mmtc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhuut20noojpqoqn4mmtc.jpg" alt="Synology Docker Registry search"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the registry container is started we need to do two things, one on your machine creating your Docker images and one on the server (or NAS in my case)&lt;/p&gt;

&lt;h3&gt;
  
  
  Local changes
&lt;/h3&gt;

&lt;p&gt;Open up your Docker Desktop client and navigate to Settings -&amp;gt; Docker Engine. On this screen we'll add a property to the JSON object for &lt;code&gt;insecure-registries&lt;/code&gt;. It's an array of strings, below is an example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nl"&gt;"insecure-registries"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"192.168.1.123:9500"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;


&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I'm running my registry on port 9500 so I'll need to specify it in the URL. Use the port you mapped when starting the container. Now that's done you should be able to push to that registry with:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

docker image push 192.168.1.123:9500/&lt;span class="o"&gt;{&lt;/span&gt;imageName&lt;span class="o"&gt;}&lt;/span&gt;:&lt;span class="o"&gt;{&lt;/span&gt;version&lt;span class="o"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;At this point you should have a running registry with an image in it!&lt;/p&gt;

&lt;h3&gt;
  
  
  Server / NAS Changes
&lt;/h3&gt;

&lt;p&gt;This part gets a bit inception-y. We have to tell the NAS that there's an insecure registry we'd like to use to retrieve images from that it's hosting itself. This means SSH'ing into the Synology and updating a configuration file. Once SSH'd in we'll need to update &lt;code&gt;/var/packages/Docker/etc/dockerd.json&lt;/code&gt; as sudo so that we can write the changes back to the file system. Once in this file is open (I use vi for quick changes like this) we can add an entry for the same property that we added client side: &lt;code&gt;insecure-registries&lt;/code&gt; with the same array parameter with one value. What I found weird and is most likely a fluke is that I had to add the new entry into the correct alphabetically ordered location in the JSON object. It &lt;strong&gt;shouldn't&lt;/strong&gt; matter but it did 🤷‍♂️.&lt;/p&gt;

&lt;p&gt;Once the update is done to the file, save and close it. We'll need to restart the Docker service in order for it to recognize the change in configuration. You can do this two ways:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl restart pkgctl-Docker


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

synopkgctl restart pkgctl-Docker


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The first one is standard systemd on Linux, the second one being Synology's command line tool for managing their packages.&lt;/p&gt;

&lt;p&gt;Once this is done use a tool like Portainer or open the settings for the Docker view in your Synology dashboard and add your new repo!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwv8tmdd5blr1iedqtilq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwv8tmdd5blr1iedqtilq.jpg" alt="Synology use local Docker Registry"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading! ✌&lt;/p&gt;

</description>
      <category>docker</category>
      <category>nas</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
