---
title: Running Docker Engine on WSL 2
description: Learn how to install Docker Engine directly onto your preferred Linux distro using WSL 2 on Windows.
image: https://blog.avenuecode.com/hubfs/pexels-kelly-12530458-1.jpg
---

[AvenueCode.com](https://avenuecode.com) [News](https://avenuecode.com/news) [Contact](https://avenuecode.com/contact)

[![Avenue Code Snippets Logo](https://blog.avenuecode.com/hubfs/Avenue%20Code%20New%20Logos%20-%202023/AC-Snippets---Black.png)](https://blog.avenuecode.com/?hsLang=en-us) *menu*

- Technology
  
  [Cloud](https://blog.avenuecode.com/blog/topic/cloud?hsLang=en-us) [Delivery Infrastructure](https://blog.avenuecode.com/blog/topic/delivery-infrastructure?hsLang=en-us) [Web Experience](https://blog.avenuecode.com/blog/topic/web-experience?hsLang=en-us) [Agile Mindset](https://blog.avenuecode.com/blog/topic/agile-mindset?hsLang=en-us) [Quality First](https://blog.avenuecode.com/blog/topic/quality-first?hsLang=en-us)
  
  [Design](https://blog.avenuecode.com/blog/topic/design?hsLang=en-us) [Solution Architecture](https://blog.avenuecode.com/blog/topic/solution-architecture?hsLang=en-us) [Data & ML](https://blog.avenuecode.com/blog/topic/data-and-machine-learning?hsLang=en-us) [Mobile Experience](https://blog.avenuecode.com/blog/topic/mobile-experience?hsLang=en-us)
- [Whitepapers](https://blog.avenuecode.com/blog/topic/whitepapers?hsLang=en-us)
- [Spotlight](https://blog.avenuecode.com/blog/topic/spotlight?hsLang=en-us)
- [Extraordinary Women in Tech](https://blog.avenuecode.com/blog/topic/extraordinary-women-in-tech?hsLang=en-us)
- [Avenue Code Culture](https://blog.avenuecode.com/blog/topic/avenue-code-culture?hsLang=en-us)

- [Cloud](https://blog.avenuecode.com/blog/topic/cloud?hsLang=en-us)
- [Design](https://blog.avenuecode.com/blog/topic/design?hsLang=en-us)
- [Delivery Infrastructure](https://blog.avenuecode.com/blog/topic/delivery-infrastructure?hsLang=en-us)
- [Solution Architecture](https://blog.avenuecode.com/blog/topic/solution-architecture?hsLang=en-us)
- [Web Experience](https://blog.avenuecode.com/blog/topic/web-experience?hsLang=en-us)
- [Data & ML](https://blog.avenuecode.com/blog/topic/data-and-machine-learning?hsLang=en-us)
- [Agile Mindset](https://blog.avenuecode.com/blog/topic/agile-mindset?hsLang=en-us)
- [Mobile Experience](https://blog.avenuecode.com/blog/topic/mobile-experience?hsLang=en-us)
- [Quality First](https://blog.avenuecode.com/blog/topic/quality-first?hsLang=en-us)
- [Whitepapers](https://blog.avenuecode.com/blog/topic/whitepapers?hsLang=en-us)
- [Spotlight](https://blog.avenuecode.com/blog/topic/spotlight?hsLang=en-us)
- [Extraordinary Women in Tech](https://blog.avenuecode.com/blog/topic/extraordinary-women-in-tech?hsLang=en-us)
- [Avenue Code Culture](https://blog.avenuecode.com/blog/topic/avenue-code-culture?hsLang=en-us)

# [Running Docker Engine on WSL 2](https://blog.avenuecode.com/running-docker-engine-on-wsl-2)

- [Tweet](https://twitter.com/share)

*perm\_identity* [Isaac Nunes Borges](https://blog.avenuecode.com/running-docker-engine-on-wsl-2/author/isaac-nunes-borges?hsLang=en-us)

*schedule* 7/13/22 2:00 PM

Did you know that even if you work for a company, you can still legally use containers with Docker using WSL 2? Today I'll show you how.

Since Docker announced updates on its license agreement, Docker Desktop is exclusively for personal use, educational institutions, non-commercial open-source projects, and small businesses. Other companies need to acquire a license for Docker Desktop; this license update is only related to Docker Desktop and not to Docker or the Docker Engine.

However, there is an alternative on Windows to continue to legally use containers with Docker using WSL 2. 

##### What is Docker<https://www.docker.com/>?

[Docker](https://www.docker.com/) is an open-source containerization platform. It enables developers to package applications into containers, which are standardized, executable components combining application source code with the operating system (OS) libraries and dependencies required to run that code in any environment.

##### What is WSL 2?

The [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/about) lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual boot setup.

##### Docker + WSL 2

In this article, I will show you how to install and configure Docker Engine directly on Linux using WSL 2 on Windows.

The first thing you have to do is make sure Docker Desktop and Docker CLI are not installed on your Windows, since later you will have to install the Docker Engine alone.

There are a couple important advantages to running Docker Engine on WSL 2, but there is also one disadvantage.

##### Advantages

1. It consumes the minimum memory needed to run Docker Daemon (Docker server).
2. It's faster than Docker Desktop because it's running directly inside the WSL 2 instance instead of on a separate Linux instance.

##### Disadvantage

1. To run Docker on another WSL 2 instance, you will need to re-install Docker on this instance or configure the socket access to share Docker between instances.

##### Requirements

1. Windows 10;
2. At least 4GB of RAM memory;
3. [WSL 2](https://docs.microsoft.com/en-us/windows/wsl/install); and
4. Linux Distro: You can choose your favorite Linux distribution like Ubuntu or Debian in the Windows Store.

Note: All commands below must be executed on Linux distro shell. They will not work with “Ubuntu 22.04 LTS” distribution at this time. They do work with the following distributions:

- Ubuntu

- Ubuntu 18.04 LTS

- Ubuntu 20.04 LTS

##### Docker Engine Installation 

- Uninstall old versions:
- ```
  sudo apt remove docker docker-engine docker.io containerd runc
  ```
- Before you install Docker, you need to run some prerequisites:
  
  ```
  sudo apt update && sudo apt upgrade -ysudo apt remove docker docker-engine docker.io containerd runc    sudo apt-get install \        apt-transport-https \        ca-certificates \        curl \        gnupg \        lsb-release -y
  ```

- Add the Docker repository on the Linux source list:
  
  ```
  sudo mkdir -p /etc/apt/keyringscurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
  ```
  
  Use the following command to set up the repository:
  
  ```
  echo \  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  ```
  
   Now let's install Docker Engine:

```
sudo apt-get updatesudo apt-get install docker-ce docker-ce-cli containerd.io -y
```

- Next, set the permission for the user to run Docker:

```
sudo usermod -aG docker $USER
```

- And install Docker Compose:

```
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-composesudo chmod +x /usr/local/bin/docker-composesudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
```

##### Running Docker Engine

- Start the service:

```
sudo service docker start
```

- Hello World example:

```
docker run hello-world
```

- Now start the SQL Server Docker Container:

```
sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=StrongPassword@123' -p 1433:1433 -d --name=sqlserver mcr.microsoft.com/mssql/server:2022-latest
```

##### Using Azure Data Studio to Connect to the SQL Server Instance

Now that our SQL Server Docker Container is up and running on port 1433, open up [Azure Data Studio](https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio?view=sql-server-ver16) and use the same credentials to connect to it.

To log in, use the configuration below:

```
    server: 127.0.0.1,1433    user: sa    pass: StrongPassword@123
```

The SQL Server connection will look like this:

![](https://lh3.googleusercontent.com/WHDQT10NZakJ48t2kCyowmfkMl9Ov1_wzO3hyz5iKgZZuJgmK5C4lVak7IMUrrvlEdgRl5bXGD6kUQrkbdPOLatnQuwCrzLIHfS2aXlbJuPmcWVRO2mAmXzfesk1ILdgMVe42uR7gkDoXRdzB2E)

 

And the SQL Server databases will look like this:

![](https://lh6.googleusercontent.com/6Xgv7BdSQOtgPz6Rk7Yr9i7T2zgXfkFyn0tRtInnV7UAiFFRcyx9xj18wgHMpn2QFDuKiVZlZHvK3ZkG4yMc2eldEhfRjzDRZdTTPpLfpJ4HwXibhRao-D8PxqOCaz_DgHuejBTMsa_C5Dg9tCc)

##### Using NoSQLBooster to Connect to the MongoDB Instance

- Now let's start the MongoDB Docker Container:

```
sudo docker run -d --name mongodb -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=user -e MONGO_INITDB_ROOT_PASSWORD=StrongPassword mongo
```

MongoDB Docker Container is up and running on port 27017. Open [NoSQLBooster](https://nosqlbooster.com/) and use the connection below:

```
mongodb://user:StrongPassword@localhost:27017
```

The MongoDB connection will appear as follows:

![](https://lh4.googleusercontent.com/JeX9B5KZ-o9mj_NL7pssbKkVLKrwpzzVI40X7EM84EdZdaadaBm-cZMOp3he6LZAV9-RMTc_5RIqsjqE1aVy_8sHYB6F0eUMwP6YCvtktlqFphTU0jtnMAdNMtonHEHpajEnbo05NapJbX65qXg)

The MongoDB databases will look like this:

![](https://lh4.googleusercontent.com/7EyYfVAr9vqaoENU0pzvL5EDKNqRPFaepAypYMwa5UD0IarRkP7qYg6MRvmLM8HVGw7LYC5obUiy20ajwF9rY6etI-ePJ8C2jbvMF1wntK9QwEqtAAJRFKTNiUD4XWPmqqJ-sHE99LWL4UdtilQ)

##### Docker UI - Portainer

One of the advantages of using Docker Desktop is its visual facility for manipulating images and containers, but we can also achieve this using [Portainer](https://www.portainer.io/), an excellent tool with an open-source version, to administer and manage these resources.

- Let's start by installing Portainer:

```
docker volume create portainer_datadocker run -d -p 8000:8000 -p 9000:9000 -p 9443:9443 --name portainer \        --restart=always \        -v /var/run/docker.sock:/var/run/docker.sock \        -v portainer_data:/data \        portainer/portainer-ce:latest   
```

Now that the installation is complete, you can log into your Portainer Server instance by opening a web browser and going to:

[http://localhost:9000](http://localhost:9000/)

After logging in, you can view all resources, such as images, containers, networks, and volumes in a very simple format. It will look something like this:

![](https://lh3.googleusercontent.com/HiSuXJAkgoR5_p24AAlCgKHOtr_yGh6XdYfA70Omn6Q8egmV_Uxia28Vue41PtM2wo8t8I-CWsKwtc6DsnU-yYbsppNVup1L4afokf8NJlvgg3sBQxjAljNPO60E9Dy6kRc_lkKLYS1vWmliBwo)

##### Conclusion

I hope you have enjoyed this tutorial on how to install the Docker Engine directly onto your preferred Linux distro using WSL 2 on Windows, as well as how to manipulate and manage all Docker resources using Portainer. Comment if you have any questions or suggestions!

 

##### References

- "[Guia rápido do WSL 2 + Docker](https://github.com/codeedu/wsl2-docker-quickstart)" argentinaluiz. GitHub.
- "[Install Docker on Windows (WSL) without Docker Desktop](https://dev.to/bowmanjd/install-docker-on-windows-wsl-without-docker-desktop-34m9)" Jonathan Bowman. Dev.to.
- "[Run Docker in WSL (Windows 10/11) without Docker Desktop](https://medium.com/geekculture/run-docker-in-windows-10-11-wsl-without-docker-desktop-a2a7eb90556d)" Sung Kim. Medium.
- "[What is the Windows Subsystem for Linux?](https://docs.microsoft.com/en-us/windows/wsl/about)" docs.Microsoft.
- "[Docker](https://www.ibm.com/in-en/cloud/learn/docker)" IBM Cloud Education. IBM.

---

### Author

# Isaac Nunes Borges

 Isaac Nunes Borges is a Software Engineer at Avenue Code. He holds a degree in Computer Science and has been working as a software developer since 2013. He enjoys sports, principally NBA and soccer, and he also loves a good beer.

---

### Related Posts

### New Horizons for Solution Architects

[READ MORE](https://blog.avenuecode.com/new-horizons-for-solution-architects?hsLang=en-us)

### The Domains of the Cloud Center of Excellence (CCoE)

[READ MORE](https://blog.avenuecode.com/the-domains-of-the-cloud-center?hsLang=en-us)

### Asymmetric Cryptography

[READ MORE](https://blog.avenuecode.com/asymmetric-cryptography?hsLang=en-us)

### Terraform 101: An Introduction to Infrastructure as Code

[READ MORE](https://blog.avenuecode.com/terraform-101?hsLang=en-us)

### Leave a Comment!

### Avenue Code Social

[![Facebook Icon](https://blog.avenuecode.com/hubfs/Images/Blog/facebook.png?t=1486470796564)](https://www.facebook.com/avenuecode)

[![Twitter Icon](https://blog.avenuecode.com/hubfs/Images/Blog/twitter.png?t=1486470796842)](https://twitter.com/AvenueCode)

[![LinkedIn Icon](https://blog.avenuecode.com/hubfs/Images/Blog/linkedin.png?t=1486470796556)](https://www.linkedin.com/company/avenuecode/)

### Newsletter

Want to stay on top of all tips and news from Avenue Code?

### Popular Snippets

![Avenue Code-primary versions_logo white avenue code endorsement 2](https://blog.avenuecode.com/hs-fs/hubfs/Avenue%20Code%20New%20Logos%20-%202023/Avenue%20Code-primary%20versions_logo%20white%20avenue%20code%20endorsement%202.png?width=1180&name=Avenue%20Code-primary%20versions_logo%20white%20avenue%20code%20endorsement%202.png "Avenue Code-primary versions_logo white avenue code endorsement 2")

### About Us

- [Who We Are](https://www.avenuecode.com/who-we-are)
- [What We Do](https://www.avenuecode.com/what-we-do)
- [Portfolio](https://www.avenuecode.com/portfolio)
- [Partners](https://www.avenuecode.com/partners)
- [News](https://www.avenuecode.com/news)
- [Events](https://www.avenuecode.com/events)
- [Blog](https://blog.avenuecode.com/)
- [Contact](https://www.avenuecode.com/contact)

### Our Offices

San Francisco

[+1 415 766 4178](tel:+553125161448) [ac.inquiries@avenuecode.com](mailto:brazil.info@avenuecode.com)

Belo Horizonte

[+55 31 2516 1448](tel:+553125161448) [brazil.info@avenuecode.com](mailto:brazil.info@avenuecode.com)

São Paulo

[+55 11 3205 3232](tel:+553125161448) [brazil.info@avenuecode.com](mailto:brazil.info@avenuecode.com)

### We're Hiring!

- [Belo Horizonte](https://www.avenuecode.com/who-we-are)
- [New York](https://www.avenuecode.com/what-we-do)
- [San Francisco](https://www.avenuecode.com/portfolio)
- [São Paulo](https://www.avenuecode.com/partners)

---

©2015 - 2017 Avenue Code

[![Facebook Icon](https://blog.avenuecode.com/hubfs/Images/Icons/facebook-2.png)](https://www.facebook.com/avenuecode) [![Twitter Icon](https://blog.avenuecode.com/hubfs/Images/Icons/twitter-2.png)](https://twitter.com/AvenueCode) [![LinkedIn Icon](https://blog.avenuecode.com/hubfs/Images/Icons/linkedin-2.png)](https://www.linkedin.com/company/avenue-code) [![Glassdoor Icon](https://blog.avenuecode.com/hubfs/Images/Icons/glassdoor-icon-1.png)](https://www.glassdoor.com/Overview/Working-at-Avenue-Code-EI_IE456173.11,22.htm) [![YouTube Icon](https://blog.avenuecode.com/hubfs/Images/Icons/youtube-2.png)](https://www.youtube.com/user/AvenueCodePlay)

Please enable JavaScript to view the [comments powered by Disqus.](http://disqus.com/?ref_noscript)

© 2026 Avenue Code

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Isaac Nunes Borges",
    "url" : "https://blog.avenuecode.com/author/isaac-nunes-borges"
  },
  "dateModified" : "2022-10-12T19:52:44.162Z",
  "datePublished" : "2022-07-13T17:00:00.000Z",
  "headline" : "Running Docker Engine on WSL 2",
  "image" : [ "https://blog.avenuecode.com/hubfs/pexels-kelly-12530458-1.jpg" ],
  "mainEntityOfPage" : {
    "@id" : "https://blog.avenuecode.com/running-docker-engine-on-wsl-2",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://blog.avenuecode.com/hubfs/Avenue%20Code%20New%20Logos%20-%202023/Avenue%20Code-primary%20versions_LOGO%20HORIZONTAL%20group%201-7.png"
    },
    "name" : "Avenue Code"
  }
}
```