Install Docker On Wsl Ubuntu

A Linux Dev Environment on Windows with WSL 2, Docker Desktop And the docker docs. Docker Desktop WSL 2 backend. Below is valid only for WSL1. It seems that docker cannot run inside WSL. What they propose is to connect the WSL to your docker desktop running in windows: Setting Up Docker for Windows and WSL. In the docker forums they also refer. Open Ubuntu WSL App. Currently, there are two long term Ubuntu versions available on Microsoft Store to install: Ubuntu 18.04 LTS & Ubuntu 20.04 LTS Linux. To get started with Docker Engine on Ubuntu, make sure youmeet the prerequisites, theninstall Docker.

Modern project development often requires developers to understand not one or two core technologies, but a whole range of them. It can involve different programming languages, structures, and databases or cloud operating systems. However, one of the main challenges is scaling and configuring the interactions and dependencies of these components between themselves.

To solve such tasks, companies and developers often resort to container technology, which integrates and packages all kinds of technologies, programs, and code into one ecosystem in the form of containers. One of the most popular solutions in this area is Docker Containers, which has such advantages:

  • isolate environment,
  • scaling options,
  • dependency management,
  • host autonomy,
  • simple software layout.

At the same time, we should note that the basic operating system for Docker is Linux. However, for developers who prefer Windows, some solutions use virtual machine technologies - Docker for Windows and Docker ToolBox. But their use is not always practical, as virtual machines often require additional system resources and more advanced configuration options for interaction with the main operating system.

There is another approach for such cases that uses Windows Subsystem for Linux (WSL) and allows running Linux programs, including Docker, on the Windows platform.

WSL aspect and configurations

Windows Subsystem for Linux provides functionality for Linux files, scripts, and programs in Windows 10 and Windows Server 2019. WSL does not use virtual machines but runs a compatibility layer at the system level. It provides a high integration level with the main system and allows to use most programs from repositories for Linux distributions without significant system resources.

Let’s highlight the main WSL features and aspects of its application:

  • Uses only the latest Windows 10 revisions and provides the ability to run multiple Linux distributions and associated programs.
  • WSL is not a complete Linux kernel, but just a compatibility functionality for running Linux programs. Therefore, for low-level support, it requires other tools such as virtual machines.
  • WSL can be used effectively for simple and not heavily loaded high-level programs or scripts, for example, for the bash-environment.

In this case, for complete integration of Docker with the Windows platform, we will use the latest version of the program - WSL2. It will allow avoiding the stage of creating a private virtual machine for Docker and therefore simplify its use due to system resources and data synchronization between different systems.

Complete installation procedure of the WSL2 (after this simply WSL) is fully described in the official documentation and usually does not cause any problems. Therefore, below we will only focus on the main aspects of installation and configuration.

The main steps in WSL configuration for Windows include the following:

Install Docker On Ubuntu Wsl 1

  • Checking the operating system build version.
  • Creating or logging on to Microsoft Account and joining the Windows Insider Program.
  • Enabling software options and operating system settings:
    • WSL and virtual machine platform support service.
    • Hyper-V virtualization services (required for Docker for Windows).
  • Selection of the Linux distribution and its further configuration.
  • Upgrades of Linux components to required or current versions.

Next, we will show and describe these steps briefly.

There are two ways to check the version of the operating system Windows 10. The first is to use the Windows interface and execute the winver command on the run command line. The second uses the command-line interface (or PowerShell terminal) and the execution of the systeminfo command. As a result, you will get the operating system version and it should be Windows Pro 10, higher than the 18917 build or Windows Pro 10 Insider version as in our case.

Note that Windows 10 must be PRO version as for other ones, the Hyper-V virtualization service will not be configured, and the Docker for Windows will not work.

Once the operating system version matches the requirements, you will need to join the Windows Insider Program. You can do this by opening the next options:

  1. Select Settings>Update & Security.
  2. Select the Windows Insider Program tab.
  3. Login with a Microsoft Account.
  4. Press the Run button and select the Fast option.

Note that if you do not get the above option, you need to become an administrator or check the operating system version again.

Next, we will enable necessary services and options in the Turn features on or off section as shown below :

The same can be done with the following commands in a PowerShell terminal.

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V –All

Following that, we will use the Microsoft Store and choose one of the free versions of Linux. In our case, it will be a popular Ubuntu 18.04 LTS image.

Before running the downloaded image, let's make sure that we are using the latest, which is the second version of the WSL. To check this, let's enter the commands in the PowerShell terminal:

The second command is only required if you have installed the first version of WSL. Differences between versions and how to manage WSL images are well described in documentation and tutorials.

Following that, we will launch WSL from the Start menu, and after initial configuration, we'll get the Ubuntu terminal as shown below:

Finally we are ready to install Docker.

Docker Desktop with WSL and Docker-CE

Currently, there are two options for installing Docker on Windows 10:

  • Using Docker Desktop for Windows with WSL2 backend.
  • Using WSL2 tools to install the Linux version of Docker-CE.

The first option is appropriate for developers who build their projects on Windows platform and need native Linux kernel support for Docker. That makes it possible to run containers without emulation and use the Linux workspaces. Also, we should mention that Docker with WSL2 makes the system resources (specifically, memory) less demanding since it uses the dynamic memory allocation function.

The second option provides functionality of the Linux environment, which gives an advantage for projects using its tools and repositories. Note that Docker-CE does not require a basic desktop version and the Hyper-V service. Therefore, this option allows you to run other virtual machines together with WSL for other different tasks.

In general, the usage of Docker-CE and WSL does not differ from the typical Docker usage on Linux systems. Therefore, we will only focus on configuration and customization of Docker Desktop being a popular tool for managing containers on the Windows platform.

Docker Desktop with WSL2 backend

Let's install the latest version of Docker Desktop from the official website. To download the install package and get started, you will need to log in or create a new account on Docker Hub.

Follow the instructions of the installer during the installation process. The process itself takes some time, following that, the computer will require a restart to enable the Hyper-V service.

If the installer reports a firewall or antivirus blocking during the installation, you will need to add port 445 to the firewall exceptions or rules.

After installation and rebooting, the Docker Desktop will automatically launch. During the first start, you will need to enter Docker Hub Credentials to initialize all involved services.

Once the installation is complete, the Docker Whale icon will appear in the taskbar, and by clicking on it, we can configure it further.

Next, we will initialize the WSL2 backend functionality in the installed application. To do this, select Settings from the menu and activate WSL2 backend engine on the General tab.

After applying these actions, you will need to reboot the Docker application and then confirm the activation of WSL integration for Docker Desktop.

Next, you should activate the previously installed WSL Ubuntu 18.04 LTS image in Docker settings under the Resourcestab.

After implementing the changes, let us check to see if everything has been installed correctly. On the PowerShell terminal using the standard docker version command:

As a result, we can see that Docker Desktop has been installed correctly and is ready for use. But before connecting, let's highlight some features of using it on a Windows system:

  • If you want to connect Windows or Linux containers, you should change the corresponding option in Docker settings as shown below:
  • Project files should be stored in proper folder and environment to avoid case-sensitive errors in the Windows project. One of the solutions that will help to use Windows project files in a Linux environment is the mklink command which creates a symbolic link to the project folder.
    mklink /D C:project_directory wsl$ubuntu-18.03homeuserproject_directory
  • Local domains should be registered in their respective host's file. Windows 10 host files are located in: C:WindowsSystem32driversetchosts

Other features and options for using Docker on Windows are generally the same as in the Linux version.

Next, let's run the simplest examples to demonstrate the features of Docker Desktop with WSL.

Running Docker on Windows

To demonstrate Docker functionality, we will use Docker Hub, which contains most ready-to-use containers.

As an example of Docker's workability, we will take the simplest container that displays the phrase 'Hello-World'. To do this, we need to run two commands on the command line or the PowerShell terminal.

docker pull hello-world

docker run hello-world

As we can see, the messages are displayed, and Docker Desktop works correctly. Next, let’s try to run the Windows Server container from its official image. To do this, let's run the following commands:

The first command downloads and runs the associated container, while the second command runs it with parameters that will output the container in the command line environment as shown below:

As a result, we have the Windows operating system running in the container. For test, we've also executed the standard command dir and tasklist and everything works correctly.

Now, we will create our container on the Docker Hub with the output of the test phrase at its startup. To do this, first of all, let's check the downloaded containers.

docker images

From the container ID, we will create a new one in our repository on Docker Hub with the following command:

After executing this command, a new container will be created. We will check its performance by running it from the PowerShell terminal using the command:

docker run <user>/windows-test-image

As we can see, the container is working.


In this article, we showed how to use containers using Docker on a Windows platform. We walked through the installation and configuration features of the Windows Subsystem for Linux as well as Docker for Windows systems. Perhaps this information will help and simplify the use of container technology with Docker and Windows.

Estimated reading time: 10 minutes

A Linux Dev Environment on Windows with WSL 2, Docker Desktop And the docker docs. Docker Desktop WSL 2 backend. Below is valid only for WSL1. It seems that docker cannot run inside WSL. What they propose is to connect the WSL to your docker desktop running in windows: Setting Up Docker for Windows and WSL. In the docker forums they also refer. Before starting the tutorial, I am assuming that you already have the WSL with Ubuntu on your Windows 10 or server system. If not then follow the tutorial: Steps to enable WSL with Ubuntu. Open Ubuntu WSL App. Currently, there are two long term Ubuntu versions available on Microsoft Store to install: Ubuntu 18.04 LTS & Ubuntu 20.04 LTS Linux.

To get started with Docker Engine on Ubuntu, make sure youmeet the prerequisites, theninstall Docker.


OS requirements

Install Docker On Wsl Ubuntu

To install Docker Engine, you need the 64-bit version of one of these Ubuntuversions:

  • Ubuntu Groovy 20.10
  • Ubuntu Focal 20.04 (LTS)
  • Ubuntu Bionic 18.04 (LTS)
  • Ubuntu Xenial 16.04 (LTS)

Docker Engine is supported on x86_64 (or amd64), armhf, and arm64 architectures.

Uninstall old versions

Older versions of Docker were called docker,, or docker-engine.If these are installed, uninstall them:

It’s OK if apt-get reports that none of these packages are installed.

The contents of /var/lib/docker/, including images, containers, volumes, andnetworks, are preserved. If you do not need to save your existing data, and want tostart with a clean installation, refer to the uninstall Docker Enginesection at the bottom of this page.

Supported storage drivers

Docker Engine on Ubuntu supports overlay2, aufs and btrfs storage drivers.

Docker Engine uses the overlay2 storage driver by default. If you need to useaufs instead, you need to configure it manually.See use the AUFS storage driver

Installation methods

You can install Docker Engine in different ways, depending on your needs:

  • Most usersset up Docker’s repositories and installfrom them, for ease of installation and upgrade tasks. This is therecommended approach.

  • Some users download the DEB package andinstall it manually and manageupgrades completely manually. This is useful in situations such as installingDocker on air-gapped systems with no access to the internet.

  • In testing and development environments, some users choose to use automatedconvenience scripts to install Docker.

Install using the repository

Docker In Wsl Ubuntu Commands

Before you install Docker Engine for the first time on a new host machine, you needto set up the Docker repository. Afterward, you can install and update Dockerfrom the repository.

Set up the repository

  1. Update the apt package index and install packages to allow apt to use arepository over HTTPS:

  2. Add Docker’s official GPG key:

  3. Use the following command to set up the stable repository. To add thenightly or test repository, add the word nightly or test (or both)after the word stable in the commands below. Learn about nightly and test channels.

    Note: The lsb_release -cs sub-command below returns the name of yourUbuntu distribution, such as xenial. Sometimes, in a distributionlike Linux Mint, you might need to change $(lsb_release -cs)to your parent Ubuntu distribution. For example, if you are using Linux Mint Tessa, you could use bionic. Docker does not offer any guarantees on untestedand unsupported Ubuntu distributions.

Install Docker Engine

  1. Update the apt package index, and install the latest version of DockerEngine and containerd, or go to the next step to install a specific version:

    Got multiple Docker repositories?

    If you have multiple Docker repositories enabled, installingor updating without specifying a version in the apt-get install orapt-get update command always installs the highest possible version,which may not be appropriate for your stability needs.

  2. To install a specific version of Docker Engine, list the available versionsin the repo, then select and install:

    a. List the versions available in your repo:

    b. Install a specific version using the version string from the second column, for example, 5:18.09.1~3-0~ubuntu-xenial.

  3. Verify that Docker Engine is installed correctly by running the hello-worldimage.

    This command downloads a test image and runs it in a container. When thecontainer runs, it prints an informational message and exits.

Docker Engine is installed and running. The docker group is created but no usersare added to it. You need to use sudo to run Docker commands.Continue to Linux postinstall to allow non-privilegedusers to run Docker commands and for other optional configuration steps.

Upgrade Docker Engine

To upgrade Docker Engine, first run sudo apt-get update, then follow theinstallation instructions, choosing the newversion you want to install.

Install from a package

If you cannot use Docker’s repository to install Docker Engine, you can download the.deb file for your release and install it manually. You need to downloada new file each time you want to upgrade Docker.

  1. Go to,choose your Ubuntu version, then browse to pool/stable/, choose amd64,armhf, or arm64, and download the .deb file for the Docker Engineversion you want to install.

    Note: To install a nightly or test (pre-release) package,change the word stable in the above URL to nightly or test.Learn about nightly and test channels.

  2. Install Docker Engine, changing the path below to the path where you downloadedthe Docker package.

    The Docker daemon starts automatically.

  3. Verify that Docker Engine is installed correctly by running the hello-worldimage.

    This command downloads a test image and runs it in a container. When thecontainer runs, it prints an informational message and exits.

Docker Engine is installed and running. The docker group is created but no usersare added to it. You need to use sudo to run Docker commands.Continue to Post-installation steps for Linux to allownon-privileged users to run Docker commands and for other optional configurationsteps.

Upgrade Docker Engine

To upgrade Docker Engine, download the newer package file and repeat theinstallation procedure, pointing to the new file.

Install using the convenience script

Docker provides convenience scripts at get.docker.comand for installing edge andtesting versions of Docker Engine - Community into development environments quickly andnon-interactively. The source code for the scripts is in thedocker-install repository.Using these scripts is not recommended for productionenvironments, and you should understand the potential risks before you usethem:

  • The scripts require root or sudo privileges to run. Therefore,you should carefully examine and audit the scripts before running them.
  • The scripts attempt to detect your Linux distribution and version andconfigure your package management system for you. In addition, the scripts donot allow you to customize any installation parameters. This may lead to anunsupported configuration, either from Docker’s point of view or from your ownorganization’s guidelines and standards.
  • The scripts install all dependencies and recommendations of the packagemanager without asking for confirmation. This may install a large number ofpackages, depending on the current configuration of your host machine.
  • The script does not provide options to specify which version of Docker to install,and installs the latest version that is released in the “edge” channel.
  • Do not use the convenience script if Docker has already been installed on thehost machine using another mechanism.

This example uses the script at toinstall the latest release of Docker Engine - Community on Linux. To install the latesttesting version, use instead. Ineach of the commands below, replace each occurrence of get with test.


Always examine scripts downloaded from the internet beforerunning them locally.

If you would like to use Docker as a non-root user, you should now consideradding your user to the “docker” group with something like:

Remember to log out and back in for this to take effect!


Docker In Wsl Ubuntu Windows 10

Adding a user to the “docker” group grants them the ability to run containerswhich can be used to obtain root privileges on the Docker host. Refer toDocker Daemon Attack Surfacefor more information.

Docker Engine - Community is installed. It starts automatically on DEB-based distributions. OnRPM-based distributions, you need to start it manually using the appropriatesystemctl or service command. As the message indicates, non-root users can’trun Docker commands by default.


To install Docker without root privileges, seeRun the Docker daemon as a non-root user (Rootless mode).

Upgrade Docker after using the convenience script

If you installed Docker using the convenience script, you should upgrade Dockerusing your package manager directly. There is no advantage to re-running theconvenience script, and it can cause issues if it attempts to re-addrepositories which have already been added to the host machine.

Docker In Wsl Ubuntu Download

Uninstall Docker Engine

  1. Uninstall the Docker Engine, CLI, and Containerd packages:

  2. Images, containers, volumes, or customized configuration files on your hostare not automatically removed. To delete all images, containers, andvolumes:

Install Docker In Wsl Ubuntu

Install Docker On Wsl Ubuntu Download

You must delete any edited configuration files manually.

Next steps

  • Continue to Post-installation steps for Linux.
  • Review the topics in Develop with Docker to learn how to build new applications using Docker.

Docker Wsl Ubuntu 20.04

Install Docker On Wsl Ubuntu 64-bit

requirements, apt, installation, ubuntu, install, uninstall, upgrade, update