<?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: Nathan Crum</title>
    <description>The latest articles on DEV Community by Nathan Crum (@crumdev).</description>
    <link>https://dev.to/crumdev</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%2F50448%2F21e3b22d-55ab-4c3b-9447-e6d897033aae.jpeg</url>
      <title>DEV Community: Nathan Crum</title>
      <link>https://dev.to/crumdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/crumdev"/>
    <language>en</language>
    <item>
      <title>VSCode Dev Container Failing to Build</title>
      <dc:creator>Nathan Crum</dc:creator>
      <pubDate>Tue, 07 Mar 2023 15:19:48 +0000</pubDate>
      <link>https://dev.to/crumdev/vscode-dev-container-failing-to-build-ap4</link>
      <guid>https://dev.to/crumdev/vscode-dev-container-failing-to-build-ap4</guid>
      <description>&lt;p&gt;I hope this helps others who may have come across this problem. A workspace I have with a dev container that has worked in the past was unable to build suddenly. The error I was getting was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker: Error response from daemon: invalid mount config &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="nb"&gt;type&lt;/span&gt; 
&lt;span class="s2"&gt;"bind"&lt;/span&gt;: &lt;span class="nb"&gt;bind source &lt;/span&gt;path does not exist: 
&lt;span class="se"&gt;\\&lt;/span&gt;wsl.localhost&lt;span class="se"&gt;\U&lt;/span&gt;buntu&lt;span class="se"&gt;\m&lt;/span&gt;nt&lt;span class="se"&gt;\w&lt;/span&gt;slg&lt;span class="se"&gt;\r&lt;/span&gt;untime-dir&lt;span class="se"&gt;\w&lt;/span&gt;ayland-0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After a while of searching I navigated to \wsl.localhost\Ubuntu\mnt\wslg\runtime-dir\ on my Windows laptop and found that there was a &lt;strong&gt;wayland-0&lt;/strong&gt; and a &lt;strong&gt;wayland-0.lock&lt;/strong&gt; file in the folder. I deleted these files and to rebuild and reopen my workspace in the dev container. This time it was successful and those files were not recreated. I can't tell you why this was an issue. I can only share what worked in my case. YMMV&lt;/p&gt;

</description>
      <category>docker</category>
      <category>vscode</category>
      <category>wsl</category>
    </item>
    <item>
      <title>Replace Docker with Rancher Desktop and WSL2 on Windows</title>
      <dc:creator>Nathan Crum</dc:creator>
      <pubDate>Mon, 07 Feb 2022 16:15:46 +0000</pubDate>
      <link>https://dev.to/crumdev/replace-docker-with-rancher-desktop-and-wsl2-on-windows-5d16</link>
      <guid>https://dev.to/crumdev/replace-docker-with-rancher-desktop-and-wsl2-on-windows-5d16</guid>
      <description>&lt;p&gt;&lt;em&gt;Updated to include instructions for insecure registry.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How far we've come
&lt;/h2&gt;

&lt;p&gt;Prior to version 1.0 of Rancher Desktop it was an interesting alternative to Docker Desktop in Windows and in many cases it may have been all many users needed. Working in a larger company with private on premises registries, custom Certificate Authorities, and heavy Visual Studio use with their Docker integration proved unable to work.&lt;/p&gt;

&lt;p&gt;Now that 1.0 has released I decided to give it another try. I am thoroughly impressed with the progress this team has made and the strides they have taken to make it as accessible to as many people and the way they work as possible. Today I'm going to show you how easily you can replace docker desktop and work with a private registry protected by a Custom CA or an insecure registry you might be using if you are experimenting with hosting your own images.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using dockerd as the runtime
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.rancherdesktop.io/installation" rel="noopener noreferrer"&gt;Rancher Desktop&lt;/a&gt; has plenty of info on installing the tool so refer the the link for those instructions and I will get right into configuration.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;While you can have Docker Desktop and Rancher Desktop installed on the same machine, make sure that you completely close the Docker Desktop application before running Rancher Desktop as they both will want to use the same socket.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's get started! Open Rancher Desktop and navigate to the "Kubernetes Settings" tab then select "dockerd(moby)" as the container runtime. If you selected this during installation you can skip to Working with a custom CA or Using an insecure registry depending on your use case. You will be warned that this will cause Kubernetes to restart. Accept this and continue.&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%2Fw2nx17aubhw7n96bw3vd.PNG" 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%2Fw2nx17aubhw7n96bw3vd.PNG" alt="Moby container runtime toggle"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you have already built images with containerd and nerdctl these get stored in a way that dockerd cannot access and you will need to build those again later.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After some time Kubernetes will finish restarting and you can start using the same docker cli commands you have always used. Because dockerd is also using the same sockets for the daemon as Docker Desktop your same docker extensions for VS Code and Visual Studio will work just as they had before.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working with a custom CA
&lt;/h2&gt;

&lt;p&gt;If you need to work with a container registry that is using a Custom CA then you will run into an error like below if you try to push or pull using it. This is because docker daemon now lives in the rancher-desktop wsl instance which does not inherently trust the same CA's your laptop may have installed.&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%2Fsd8539u4ot327144lujy.png" 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%2Fsd8539u4ot327144lujy.png" alt="x509 error"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to correct this you must copy your root and intermediary CA certs to &lt;code&gt;\\wsl$\rancher-desktop\usr\local\share\ca-certificates&lt;/code&gt;. This can be pasted in Windows Explorer to easily navigate to the folder.&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%2F64mq06qomg7m9zcspop7.png" 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%2F64mq06qomg7m9zcspop7.png" alt="Custom Certs Pasted into WSL cert path"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the certs have been copied over open your terminal and connect to the rancher-desktop shell. Then run the command &lt;code&gt;update-ca-certificates&lt;/code&gt; as shown below.&lt;/p&gt;

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

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; wsl &lt;span class="nt"&gt;-d&lt;/span&gt; rancher-desktop &lt;span class="nt"&gt;-e&lt;/span&gt; /bin/sh

&lt;span class="c"&gt;# Updates the certificates to include your custom ones&lt;/span&gt;
&lt;span class="c"&gt;# in /etc/ssl/certs&lt;/span&gt;
/mnt/c/Users/&lt;span class="o"&gt;{&lt;/span&gt;user&lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; update-ca-certificates


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

&lt;/div&gt;

&lt;p&gt;After you have updated the certs verify that they show in /etc/ssl/certs. It will rename them to something like &lt;code&gt;ca-cert-{filename.ext}.pem&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now quit and restart the Rancher Desktop application in windows. When it has completed starting up again you should now be able to successfully connect and work with your private 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%2Frubl38ei9fuxtaexcg0u.png" 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%2Frubl38ei9fuxtaexcg0u.png" alt="Successful docker pull from private registry"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Using an insecure registry
&lt;/h2&gt;

&lt;p&gt;If you have setup a basic registry for storing your images on premises and you don't have a trusted CA cert for SSL, then you might encounter an error similar to below.&lt;/p&gt;

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

...http: server gave HTTP response to HTTPS client


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

&lt;/div&gt;

&lt;p&gt;To trust the registry we first need to create a file at /etc/docker/daemon.json on the WSL2 instance where the daemon is running&lt;/p&gt;

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

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; wsl &lt;span class="nt"&gt;-d&lt;/span&gt; rancher-desktop &lt;span class="nt"&gt;-e&lt;/span&gt; vi /etc/docker/daemon.json


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

&lt;/div&gt;

&lt;p&gt;Paste in the following being sure to edit the registry:port to match the one you are using:&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"insecure-registries"&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="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"192.168.1.100:5000"&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="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;Then create a file at /etc/default/docker:&lt;/p&gt;

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

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; wsl &lt;span class="nt"&gt;-d&lt;/span&gt; rancher-desktop &lt;span class="nt"&gt;-e&lt;/span&gt; vi /etc/default/docker


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

&lt;/div&gt;

&lt;p&gt;And paste this as the contents:&lt;/p&gt;

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

&lt;span class="nv"&gt;DOCKER_OPTS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"--config-file=/etc/docker/daemon.json"&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Now quit and restart rancher desktop and push/pull and image for the insecure registry again to confirm it is working.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>docker</category>
      <category>rancher</category>
      <category>containers</category>
    </item>
  </channel>
</rss>
