Install Docker On Ubuntu Wsl



-->

Fix the Docker mounting issue in WSL terminal by inserting this content in /etc/wsl.conf. Create the file if it doesn’t exist. If you’re using a distro based on Ubuntu, you can install. Install Apache web server on WSL. Now, in the Windows 10 search box, type Ubuntu and run it. As we know installing Apache is not a Sisyphean task on Ubuntu and the same goes for Ubuntu 20.04 Linux app running on Windows subsystem for Linux. Just run the single Linux command given below: sudo apt install apache2. The manual install steps for WSL are listed below and can be used to install Linux on any version of Windows 10. Note If you run into an issue during the install process, check the Troubleshooting installation section at the bottom of this page.

  • 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.
  • Although after installing the Docker, it will automatically install its own WSL 2 Linux distro on your system as the default one. Thus, you can easily start using it from PowerShell. In case you want to enable the docker support to other available WSL Linux distros then simply go to the Docker Desktop app, select the Resources option given on.

There are several scenarios in which you may not be able (or want) to, install WSL Linux distros via the Microsoft Store. Specifically, you may be running a Windows Server or Long-Term Servicing (LTSC) desktop OS SKU that doesn't support Microsoft Store, or your corporate network policies and/or admins to not permit Microsoft Store usage in your environment.

In these cases, while WSL itself is available, how do you download and install Linux distros in WSL if you can't access the store?

Note: Command-line shell environments including Cmd, PowerShell, and Linux/WSL distros are not permitted to run on Windows 10 S Mode. This restriction exists in order to ensure the integrity and safety goals that S Mode delivers: Read this post for more information.

Downloading distributions

If the Microsoft Store app is not available, you can download and manually install Linux distros by clicking these links:

Install Docker On Ubuntu 18.04 Wsl

This will cause the <distro>.appx packages to download to a folder of your choosing. Follow the installation instructions to install your downloaded distro(s).

Downloading distros via the command line

If you prefer, you can also download your preferred distro(s) via the command line:

Download using PowerShell

To download distros using PowerShell, use the Invoke-WebRequest cmdlet. Here's a sample instruction to download Ubuntu 16.04.

Tip

If the download is taking a long time, turn off the progress bar by setting $ProgressPreference = 'SilentlyContinue'

Download using curl

Windows 10 Spring 2018 Update (or later) includes the popular curl command-line utility with which you can invoke web requests (i.e. HTTP GET, POST, PUT, etc. commands) from the command line. You can use curl.exe to download the above distros:

In the above example, curl.exe is executed (not just curl) to ensure that, in PowerShell, the real curl executable is invoked, not the PowerShell curl alias for Invoke-WebRequest

Note: Using curl might be preferable if you have to invoke/script download steps using Cmd shell and/or .bat / .cmd scripts.

Installing your distro

If you're using Windows 10 you can install your distro with PowerShell. Simply navigate to folder containing the distro downloaded from above, and in that directory run the following command where app_name is the name of your distro .appx file.

If you are using Windows server, or run into problems running the command above you can find the alternate install instructions on the Windows Server documentation page to install the .appx file by changing it to a zip file.

Once your distribution is installed, follow the normal instructions to * Update from WSL 1 to WSL 2 or create a new user account and password.

At Build 2020 Microsoft announced support for GPU compute on Windows Subsystem for Linux 2. Ubuntu is the leading Linux distribution for WSL and a sponsor of WSLConf. Canonical, the publisher of Ubuntu, provides enterprise support for Ubuntu on WSL through Ubuntu Advantage.

This guide will walk early adopters through the steps on turning their Windows 10 devices into a CUDA development workstation with Ubuntu on WSL.

For our purposes we will be setting up Jupyter Notebook in Docker with CUDA on WSL. These instructions can be adapted to set up other CUDA GPU compute workloads on WSL.

Install Windows 10 Insiders Dev Channel

To begin, we need the latest Windows 10 Insider build released today, June 17, 2020. You will need to register as a Windows Insider if you have not already, enroll your device in the Dev Channel (previously known as the ‘Fast Ring’), and then upgrade to Windows 10 build number 20150 or above.

Consult the Windows Insider documentation for more information on registering as an Insider, enrolling your device, and upgrading your machine to the Dev Channel.

Enable WSL 2

In future updates to Windows you will simply need to use the following to enable WSL:

For now, open PowerShell as Administrator.

First enable WSL 1:

Then enable WSL 2:

Restart Windows 10:

This step will become redundant in the future after WSL 2 becomes the default, but for now return to PowerShell and make WSL 2 your default before installing Ubuntu:

To read more about Ubuntu on WSL, visit ubuntu.com/wsl. For a more detailed look at enabling WSL on Windows, check out our tutorial. To convert existing WSL 1 installs to WSL 2, see my blog on the general availability of WSL 2.

Install Ubuntu on WSL

Install Ubuntu from the Microsoft Store:

For other ways to install Ubuntu on WSL, see our WSL wiki.

Install Windows Terminal

Optionally, you may install the new Windows Terminal from the Microsoft Store. It is has many features, such as GPU acceleration and customizability, that improves the Ubuntu experience on WSL over the traditional Windows console.

Install Docker On Ubuntu 20.04 Wsl

Windows Terminal can also be installed from the project’s GitHub page.

Setup Ubuntu on WSL

Open Ubuntu from the Windows Start Menu and configure your WSL user. This user is separate from your Windows user:

If you downloaded Windows Terminal you can then close the old console and re-open Ubuntu from the drop-down options in the new Terminal:

Now check to make sure you are running the correct WSL 2 Linux kernel.

In Ubuntu:

Install Docker On Ubuntu Wsl

Install Docker On Ubuntu Wsl Lts

You will need kernel 4.19.121 or higher. If you do not have kernel 4.19.121, first try:

If that does not work, make sure you have ‘Receive updates for other Microsoft products when you update Windows’ checked:

And then re-run Windows updates:

Install Nvidia Drivers on Windows 10

Next, download the appropriate driver for your GeForce or Quadro Nvidia card.

In the next few months, the NVIDIA driver will be distributed via Windows Update, which will manually downloading and installing the driver unnecessary.

You will need to join the Nvidia Developer Program for early access to the driver for now. You can read more about CUDA on WSL on the Nvidia Developer blog.

Install Docker in WSL

Install Nvidia Container Toolkit

Install docker on ubuntu wsl command

Install Docker On Ubuntu Wsl Ubuntu

Set the distribution variable, import the Nvidia repository GPG key, and then add the Nvidia repositories to the Ubuntu apt package manager:

Refresh the Ubuntu apt repositories and then install the Nvidia runtime:

Close all open terminals of Ubuntu, open a PowerShell terminal, and manually shutdown Ubuntu:

Test GPU Compute

Open a new Ubuntu terminal and start Docker:

Install Docker On Ubuntu Wsl

And then run:

If everything is configured correctly, the output should resemble:

Start A TensorFlow Container

Install Docker On Ubuntu Wsl

Open a new Ubuntu terminal and run:

Open a second Ubuntu terminal, type wslview, copy and paste the notebook URL, but then edit the URL from 127.0.0.1 to localhost:

Your default browser on Windows will launch with a GPU-accelerated Jupyter notebook:

You are now all set to begin using TensorFlow with CUDA on Ubuntu WSL.

Related blog posts

  • Ubuntu: Ubuntu on WSL 2 Is Generally Available
  • Ubuntu: New GPU and GUI features announced for WSL at Build
  • Microsoft: GPU Compute, WSL Install and WSL Update arrive in the latest Insider build for the Windows Subsystem for Linux
  • Nvidia: Announcing CUDA on Windows Subsystem for Linux 2

Additional resources

Talk to us today

Interested in running Ubuntu in your organisation?

Newsletter signup