DEV Community

Cover image for How to Create Docker Images in Windows without Docker Desktop using WSL2
Federico Navarrete
Federico Navarrete

Posted on • Updated on • Originally published at


How to Create Docker Images in Windows without Docker Desktop using WSL2

Most people are aware that Docker Desktop is not available anymore for Windows users for free, and this became a challenge. For a couple of months, I thought if there was an alternative for my team, and I came up with a solution using WSL2 and Ubuntu.

To get started you must complete two requirements:

1) Install Windows Subsystem for Linux 2 (it doesn't work with WSL1):

Install WSL | Microsoft Docs

2) Download Ubuntu from the Microsoft Store:

Get Ubuntu - Microsoft Store

After you have installed Ubuntu and opened it for the first time, you can check in PowerShell to see if the version is correct with this command:

wsl -l -v

And you must get something like this:


If it's incorrect, you can check this tutorial and upgrade your Kernel to version 2:

Manual installation steps for older versions of WSL | Microsoft Docs

And later run this command:

wsl --set version Ubuntu 2

After everything is ready, you must run the following scripts in Ubuntu:

First part:

sudo apt-get update

Second part:

sudo apt-get update
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \

curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Enter fullscreen mode Exit fullscreen mode

Third part:

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli

sudo apt-get install docker-compose
Enter fullscreen mode Exit fullscreen mode

Fourth part:

Run this line to start your Docker every time you need it.

sudo dockerd

dockerd preview

And that's all! Just open a new Ubuntu window and start playing with Docker!


If you have any issue with the network, check the following location and edit its nameserver IP to

sudo nano /etc/resolv.conf


And to prevent the file is overwritten every time, you can modify this location:

sudo nano /etc/wsl.conf

And add these lines:

generateResolvConf = false


You can also call the Docker commands from WSL

Follow me at:

LinkedIn YouTube Amazon Instagram Cyber Prophets Sharing Your Stories
LinkedIn YouTube Amazon Instagram RedCircle Podcast RedCircle Podcast

sponsor me

Top comments (0)

19 Valuable Github Repositories for Beginners

>> Check out this classic DEV post <<