<?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: Kehinde Hussein, Fasunle</title>
    <description>The latest articles on DEV Community by Kehinde Hussein, Fasunle (@fasunle).</description>
    <link>https://dev.to/fasunle</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%2F628619%2F47775742-38d5-4017-b776-5633c52fcbb2.png</url>
      <title>DEV Community: Kehinde Hussein, Fasunle</title>
      <link>https://dev.to/fasunle</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fasunle"/>
    <language>en</language>
    <item>
      <title>Setting up docker within WSL</title>
      <dc:creator>Kehinde Hussein, Fasunle</dc:creator>
      <pubDate>Sat, 28 Jun 2025 09:28:43 +0000</pubDate>
      <link>https://dev.to/fasunle/setting-up-docker-within-wsl-3bh1</link>
      <guid>https://dev.to/fasunle/setting-up-docker-within-wsl-3bh1</guid>
      <description>&lt;h2&gt;
  
  
  Why not docker desktop?
&lt;/h2&gt;

&lt;p&gt;Docker desktop is the easiest way to get started with docker on windows. However, recently there have been a number of issues. Whenever docker or windows OS is updated, docker desktop fails to start due to its inability to start the docker daemon process.&lt;/p&gt;

&lt;p&gt;You can verify this by running:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;You see the following:&lt;br&gt;
&lt;a href="https://media2.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%2Fkoh6jafi7fg845cni3aw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fkoh6jafi7fg845cni3aw.png" alt="Image description" width="664" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This shows that the client is installed correctly but the server (docker daemon) is not running.&lt;/p&gt;

&lt;p&gt;I face these issues almost every time.&lt;/p&gt;

&lt;p&gt;I explored different solution including:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Uninstalling and reinstalling with admin privileges.&lt;/li&gt;
&lt;li&gt;Downloading a new version and installing it&lt;/li&gt;
&lt;li&gt;Removing all Docker folders in %appdata%\Docker directory&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;None of the above was able to fix the issue.&lt;/p&gt;
&lt;h2&gt;
  
  
  I decided to try a new approach
&lt;/h2&gt;

&lt;p&gt;Installing the docker server withing the WSL. I check the documentation of docker here:&lt;br&gt;
&lt;a href="https://docs.docker.com/engine/install/ubuntu/" rel="noopener noreferrer"&gt;https://docs.docker.com/engine/install/ubuntu/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I started as follows:&lt;br&gt;
First open your WSL terminal. Search wsl from your windows search box, and enter.&lt;/p&gt;

&lt;p&gt;The following will be done on your wsl terminal.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 1: Uninstall any previously installed containerd services
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 2: Update apt and install docker
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release &amp;amp;&amp;amp; echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list &amp;gt; /dev/null
sudo apt-get update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 3: Install docker packages e.g docker-compose etc
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Step 4: check if your installation is complete within your WSL
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You should see something like:&lt;br&gt;
&lt;a href="https://media2.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%2Fi4okpesaar0pudqh7n0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fi4okpesaar0pudqh7n0g.png" alt="docker complete set up on wsl" width="722" height="619"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now your docker has been set up within the &lt;strong&gt;windows subsystem for linux&lt;/strong&gt; (WSL).&lt;/p&gt;
&lt;h2&gt;
  
  
  Accessing docker from outside wsl environment
&lt;/h2&gt;

&lt;p&gt;This is great! However, you cannot access this within your local desktop or computer terminal.Let us work around this.&lt;/p&gt;

&lt;p&gt;You likely use gitbash already, so we will set alias within .bashrc file such that whenever you type docker, it would invoke the one within the wsl.&lt;/p&gt;

&lt;p&gt;Locate the file ~/.bashrc using for example vim:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vim ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the following line to the .bashrc script and save&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias docker="wsl docker";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You must ensure that you have uninstall your docker desktop so as to prevent conflict.&lt;/p&gt;

&lt;p&gt;Also, close and reopen the bash terminal. This should now give you the same response as above when you executed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Add GUI for a complete set up
&lt;/h2&gt;

&lt;p&gt;Again, you can now run docker as you would with docker desktop except that there is no graphic User Interface (GUI). Let us add this next.&lt;/p&gt;

&lt;p&gt;run this command to start a container which will serve as our GUI and can be opened from the browser via port 9090.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker volume create portainer_data
docker run -d -p 9090:9000 --name=portainer \
  --restart=always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  portainer/portainer-ce
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;NOTE: if port 9090 is not free on your device, kindly remove the image by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker rm portainer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change the port and rerun the command:&lt;/p&gt;

&lt;p&gt;e.g:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d -p 9999:9000 --name=portainer \
  --restart=always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  portainer/portainer-ce
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open localhost: e.g localhost:9090 on your browser.&lt;/p&gt;

&lt;p&gt;You now have a complete docker setup for your device.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fxceurluncfzde7kumndg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fxceurluncfzde7kumndg.png" alt="The GUI run via the docker conatiner" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that if you run this for the first time, it will ask you to add username and password with which you will login subsequently.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>linux</category>
      <category>webdev</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
