Use docker containers without Docker Desktop in WSL2 with Ubuntu

Are you ready to pay for using Docker Desktop? If you’re not, then let’s just remove it from our system…

But first, let’s see if we can live without Docker Desktop for Windows.

I will assume that you already have WSL2 installed with Ubuntu, so we will not talk about this here.

Disable Docker Desktop integration with WSL2

First of all we should disable Docker Desktop integration with WSL2. We do this by goint to Docker Desktop > Settings > Resources > WSL Integration and uncheck the Enable integration with my default WSL distro. Apply and restart.

Enable systemd in WSL2 in order to run services

Open WSL from terminal and run:
sudo nano /etc/wsl.conf

In there we write:


Then we save and close the file with Ctrl+X and Y We restart WSL2 from the PowerShell:
wsl.exe --shutdown

Install Docker Engine and CLI in WSL2

Uninstall any existing docker:
sudo apt-get remove docker docker-engine containerd runc

We set up the APT repo
sudo apt-get update sudo apt-get install ca-certificates curl gnupg lsb-release

We add docker CPG:

sudo mkdir -p /etc/apt/keyringscurl | sudo curl -fsSL | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

We then setup the repo:

echo \
"deb [arch=$(dpkg --print-architecture) signedby=/
"") \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >

And we install the Docker Engine
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli docker-compose-plugin

We add our user to the docker group in order to have full control without using sudo:
sudo usermod -aG docker $USER

We start the docker service:
sudo service docker start

We verify that the docker started
sudo service docker status

If the service did not start, we make sure we don’t have an issue with the iptables version (switch iptables to legacy) – choose the option /usr/sbin/iptables-legacy from the offer you have after running this command:
sudo update-alternatives --config iptables

Start and verify the status of the docker service (everything should work now).

Install docker-compose:
sudo apt install docker-compose

Develop the next big thing!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

No spam? * Time limit is exhausted. Please reload CAPTCHA.