<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Devops on Marouane LAARIF scribbles</title>
    <link>https://blog.laarif-marouane.com/tags/devops/</link>
    <description>Recent content in Devops on Marouane LAARIF scribbles</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>marouane.laarif94@gmail.com (LAARIF Marouane)</managingEditor>
    <webMaster>marouane.laarif94@gmail.com (LAARIF Marouane)</webMaster>
    <lastBuildDate>Sun, 13 Jul 2025 13:01:11 +0100</lastBuildDate>
    <atom:link href="https://blog.laarif-marouane.com/tags/devops/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Understanding and Fixing Docker Socket Permissions</title>
      <link>https://blog.laarif-marouane.com/posts/fix-docker-socket-permission/</link>
      <pubDate>Sun, 13 Jul 2025 13:01:11 +0100</pubDate><author>marouane.laarif94@gmail.com (LAARIF Marouane)</author>
      <guid>https://blog.laarif-marouane.com/posts/fix-docker-socket-permission/</guid>
      <description>&lt;p&gt;You&amp;rsquo;re installing Ubuntu server, you get a screen where you can pick &amp;ldquo;snaps&amp;rdquo; to install, and like many, you probably opted for the convenient &amp;ldquo;Docker&amp;rdquo; checkbox during installation, expecting a smooth, out-of-the-box experience. However, to your surprise, when you tried to run your first Docker command, you were met with a frustrating &lt;strong&gt;&amp;ldquo;permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock&amp;rdquo;&lt;/strong&gt; error.&lt;/p&gt;&#xA;&lt;p&gt;This cryptic message, often followed by &lt;code&gt;Get &amp;quot;http://%2Fvar%2Frun%2Fdocker.sock/v1.48/containers/json&amp;quot;: dial unix /var/run/docker.sock: connect: permission denied&lt;/code&gt;, indicates that your user doesn&amp;rsquo;t have the necessary permissions to communicate with the Docker daemon. This leaves you in a bind, unable to use Docker without &lt;code&gt;sudo&lt;/code&gt; for every command—which isn&amp;rsquo;t ideal for workflow or security.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>You&rsquo;re installing Ubuntu server, you get a screen where you can pick &ldquo;snaps&rdquo; to install, and like many, you probably opted for the convenient &ldquo;Docker&rdquo; checkbox during installation, expecting a smooth, out-of-the-box experience. However, to your surprise, when you tried to run your first Docker command, you were met with a frustrating <strong>&ldquo;permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock&rdquo;</strong> error.</p>
<p>This cryptic message, often followed by <code>Get &quot;http://%2Fvar%2Frun%2Fdocker.sock/v1.48/containers/json&quot;: dial unix /var/run/docker.sock: connect: permission denied</code>, indicates that your user doesn&rsquo;t have the necessary permissions to communicate with the Docker daemon. This leaves you in a bind, unable to use Docker without <code>sudo</code> for every command—which isn&rsquo;t ideal for workflow or security.</p>
<p>You try to add your user to the &ldquo;docker&rdquo; group so you can run docker without sudo. And surprise again, the &ldquo;docker&rdquo; group is not created.
You create the docker group, add your user to it, and still permission error.</p>
<p><strong>Why did this happen, especially with the Ubuntu installer&rsquo;s Docker checkbox?</strong></p>
<p>The Ubuntu server installer installs Docker as a <strong>Snap package</strong>. Snaps are designed for <strong>confinement and isolation</strong>, meaning they run in a more restricted environment for security. Unlike traditional <code>apt</code> package installations, the Docker Snap does not automatically handle the creation of the <code>docker</code> group or add your user to it due to this confinement model. This leaves you without direct access to the Docker socket, forcing you to use <code>sudo</code>.</p>
<h2 id="checking-and-correcting-docker-socket-permissions">Checking and Correcting Docker Socket Permissions</h2>
<p>To check if the docker group is created run:</p>





<pre tabindex="0"><code>getent group | grep docker</code></pre><p>If the result is empty then create the group by running :</p>





<pre tabindex="0"><code>sudo groupadd docker</code></pre><p>and add your user:</p>





<pre tabindex="0"><code>sudo usermod -a -G docker {username}</code></pre><p>If your group membership is confirmed, let&rsquo;s look at the actual permissions of the Docker socket file:</p>





<pre tabindex="0"><code>ls -l /var/run/docker.sock</code></pre><p>You should typically see something like this:</p>





<pre tabindex="0"><code>srw-rw---- 1 root docker 0 Jul  X HH:MM /var/run/docker.sock</code></pre><p>Key things to look for:</p>
<ul>
<li><strong>Ownership:</strong> <code>root</code> should be the owner.</li>
<li><strong>Group:</strong> <code>docker</code> should be the group.</li>
<li><strong>Permissions:</strong> <code>srw-rw----</code> means:
<ul>
<li><code>s</code>: It&rsquo;s a socket file.</li>
<li><code>rw-</code>: Read and write for the owner (<code>root</code>).</li>
<li><code>rw-</code>: Read and write for the group (<code>docker</code>).</li>
<li><code>---</code>: No permissions for others.</li>
</ul>
</li>
</ul>
<p>If the group is <em>not</em> <code>docker</code> or the permissions are different (e.g., <code>rw-r-----</code>), it might be misconfigured.</p>
<p><strong>If the permissions are wrong, you can fix them:</strong></p>





<pre tabindex="0"><code>sudo chown root:docker /var/run/docker.sock
sudo chmod 660 /var/run/docker.sock</code></pre><p><strong>Important Note:</strong> Some guides suggest <code>sudo chmod 666 /var/run/docker.sock</code>. While this <em>will</em> fix the permission error, it&rsquo;s a <strong>security risk</strong> as it gives <em>everyone</em> read/write access to the Docker socket, which is equivalent to giving them root access to your system. <strong>Avoid <code>chmod 666</code> for the Docker socket.</strong></p>
]]></content:encoded>
    </item>
    <item>
      <title>No Built-in Ethernet? No Problem! USB Ethernet on Proxmox Explained</title>
      <link>https://blog.laarif-marouane.com/posts/proxmox-ethernet-usb-adapter/</link>
      <pubDate>Wed, 09 Jul 2025 22:01:11 +0100</pubDate><author>marouane.laarif94@gmail.com (LAARIF Marouane)</author>
      <guid>https://blog.laarif-marouane.com/posts/proxmox-ethernet-usb-adapter/</guid>
      <description>&lt;p&gt;Setting up Ethernet over USB on a Proxmox server is a common scenario, especially when your hardware lacks a built-in Ethernet port, or you need an additional network interface. Here&amp;rsquo;s a step-by-step guide on how to do it:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Important Considerations:&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Reliability:&lt;/strong&gt; While possible, USB Ethernet adapters can sometimes be less reliable than integrated or PCIe Ethernet cards. For critical production environments, a PCIe card is generally recommended if available.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Driver Support:&lt;/strong&gt; Most modern USB Ethernet adapters use common chipsets (like Realtek) that are usually supported by the Linux kernel (which Proxmox is based on). However, if you have an obscure adapter, you might need to install additional drivers.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Interface Naming:&lt;/strong&gt; Linux (and thus Proxmox) uses consistent network interface naming (e.g., &lt;code&gt;enx&lt;/code&gt; followed by part of the MAC address, or &lt;code&gt;ethX&lt;/code&gt;). Be aware that if you plug the USB adapter into a different USB port, its name might change, which can break your configuration. You can use persistent naming if this becomes an issue (see the Proxmox Network Configuration documentation for &lt;code&gt;systemd-networkd&lt;/code&gt; &lt;code&gt;link&lt;/code&gt; files).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;&lt;strong&gt;Steps to Configure Ethernet over USB in Proxmox:&lt;/strong&gt;&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Setting up Ethernet over USB on a Proxmox server is a common scenario, especially when your hardware lacks a built-in Ethernet port, or you need an additional network interface. Here&rsquo;s a step-by-step guide on how to do it:</p>
<p><strong>Important Considerations:</strong></p>
<ul>
<li><strong>Reliability:</strong> While possible, USB Ethernet adapters can sometimes be less reliable than integrated or PCIe Ethernet cards. For critical production environments, a PCIe card is generally recommended if available.</li>
<li><strong>Driver Support:</strong> Most modern USB Ethernet adapters use common chipsets (like Realtek) that are usually supported by the Linux kernel (which Proxmox is based on). However, if you have an obscure adapter, you might need to install additional drivers.</li>
<li><strong>Interface Naming:</strong> Linux (and thus Proxmox) uses consistent network interface naming (e.g., <code>enx</code> followed by part of the MAC address, or <code>ethX</code>). Be aware that if you plug the USB adapter into a different USB port, its name might change, which can break your configuration. You can use persistent naming if this becomes an issue (see the Proxmox Network Configuration documentation for <code>systemd-networkd</code> <code>link</code> files).</li>
</ul>
<hr>
<p><strong>Steps to Configure Ethernet over USB in Proxmox:</strong></p>
<p>We&rsquo;ll primarily be working with the <code>/etc/network/interfaces</code> file, which is where Proxmox manages its network configuration.</p>
<p><strong>1. Connect the USB Ethernet Adapter:</strong></p>
<ul>
<li>Plug your USB Ethernet adapter into an available USB port on your Proxmox server.</li>
<li>Connect an Ethernet cable from the adapter to your network.</li>
</ul>
<p><strong>2. Identify the USB Ethernet Interface:</strong></p>
<ul>
<li>Access your Proxmox server&rsquo;s shell (via SSH or direct console access).</li>
<li>Run the following command to list all network interfaces:</li>
</ul>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="ln">1</span><span class="cl">ip a</span></span></code></pre></div><p>or</p>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="ln">1</span><span class="cl">ifconfig -a</span></span></code></pre></div><ul>
<li>Look for a new interface that wasn&rsquo;t there before. It will likely start with <code>enx</code> followed by a long hexadecimal string (e.g., <code>enx0123456789ab</code>) or potentially <code>usb0</code> if it&rsquo;s a very simple adapter or a USB tethered device. Note down this interface name.</li>
</ul>
<p><strong>3. Edit the Network Configuration File:</strong></p>
<ul>
<li>Open the <code>/etc/network/interfaces</code> file using a text editor like <code>nano</code>:</li>
</ul>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="ln">1</span><span class="cl">nano /etc/network/interfaces</span></span></code></pre></div><p><strong>4. Add a New Network Bridge for the USB Adapter:</strong></p>
<p>Proxmox uses Linux bridges (<code>vmbrX</code>) to manage network interfaces and allow VMs/containers to access the physical network. You&rsquo;ll create a new bridge and assign your USB Ethernet interface to it.</p>
<ul>
<li><strong>Option A: DHCP Configuration (if your network has a DHCP server)</strong></li>
<li>Add the following lines to the end of the file, replacing <code>enx0123456789ab</code> with the actual name of your USB Ethernet interface:</li>
</ul>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="ln">1</span><span class="cl">auto vmbr1
</span></span><span class="line"><span class="ln">2</span><span class="cl">iface vmbr1 inet dhcp
</span></span><span class="line"><span class="ln">3</span><span class="cl">bridge-ports enx0123456789ab
</span></span><span class="line"><span class="ln">4</span><span class="cl">bridge-stp off
</span></span><span class="line"><span class="ln">5</span><span class="cl">bridge-fd <span class="m">0</span></span></span></code></pre></div><ul>
<li><strong>Option B: Static IP Configuration</strong></li>
</ul>
<p>Add the following lines, replacing <code>enx0123456789ab</code> with your USB Ethernet interface name, <code>192.168.1.10/24</code> with your desired IP address and subnet mask, and <code>192.168.1.1</code> with your gateway:</p>





<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="ln">1</span><span class="cl">   auto vmbr1
</span></span><span class="line"><span class="ln">2</span><span class="cl">   iface vmbr1 inet static       
</span></span><span class="line"><span class="ln">3</span><span class="cl">		address 192.168.1.10/24
</span></span><span class="line"><span class="ln">4</span><span class="cl">		gateway 192.168.1.1
</span></span><span class="line"><span class="ln">5</span><span class="cl">		bridge-ports enx0123456789ab
</span></span><span class="line"><span class="ln">6</span><span class="cl">		bridge-stp off
</span></span><span class="line"><span class="ln">7</span><span class="cl">		bridge-fd <span class="m">0</span></span></span></code></pre></div><ul>
<li>
<p><strong>Note:</strong> Only one bridge on your Proxmox host can have a <code>gateway</code> defined. If you already have a <code>vmbr0</code> with a gateway, do <em>not</em> add a gateway to <code>vmbr1</code>. If <code>vmbr1</code> is your <em>only</em> network connection or your primary one, then it should have the gateway.</p>
</li>
<li>
<p><strong>Explanation of the bridge parameters:</strong></p>
</li>
<li>
<p><code>auto vmbr1</code>: Tells Proxmox to bring up this bridge automatically on boot.</p>
</li>
<li>
<p><code>iface vmbr1 inet dhcp</code> (or <code>inet static</code>): Configures the bridge to get an IP address via DHCP or to use a static IP.</p>
</li>
<li>
<p><code>bridge-ports enx0123456789ab</code>: Specifies that the physical USB Ethernet interface will be a member of this bridge.</p>
</li>
<li>
<p><code>bridge-stp off</code>: Disables Spanning Tree Protocol on the bridge (generally recommended for simple home lab setups).</p>
</li>
<li>
<p><code>bridge-fd 0</code>: Sets the bridge forward delay to 0 seconds (reduces the time it takes for the bridge to start forwarding traffic).</p>
</li>
</ul>
<p><strong>5. Save and Apply Changes:</strong></p>
<ul>
<li>
<p>Save the <code>interfaces</code> file (Ctrl+O, then Enter, then Ctrl+X in <code>nano</code>).</p>
</li>
<li>
<p>Apply the network configuration changes.</p>
</li>
<li>
<p><strong>Recommended (Proxmox VE 7.0+ with <code>ifupdown2</code>):</strong></p>
</li>
</ul>





<pre tabindex="0"><code> systemctl restart networking</code></pre><p>Then, you can verify the status:</p>





<pre tabindex="0"><code>systemctl status networking</code></pre><p>And apply changes in the Proxmox GUI by clicking &ldquo;Apply Configuration&rdquo; in the Network section of your node.</p>
<ul>
<li><strong>If <code>systemctl restart networking</code> doesn&rsquo;t work or you&rsquo;re on an older Proxmox version, or for more critical changes (requires a brief network outage):</strong></li>
</ul>





<pre tabindex="0"><code>reboot</code></pre><p><strong>6. Verify Network Connectivity:</strong></p>
<ul>
<li>After applying changes or rebooting, check if your Proxmox host has network connectivity through the new USB Ethernet adapter.</li>
</ul>





<pre tabindex="0"><code>ip a</code></pre><p>Verify that <code>vmbr1</code> (or whatever bridge name you used) has an IP address.</p>





<pre tabindex="0"><code>ping google.com</code></pre><p>or ping an IP address on your local network.</p>
]]></content:encoded>
    </item>
  </channel>
</rss>
