Install Docker On Ubuntu Wsl

March 2, 2020 by Matt Hernandez, @fiveisprime

Easywsl Tool Can Turn Linux Docker Image Into Windows 10 Wsl Distro. Windows10 安装wsl2 Ubuntu20 04 并设置docker 环境 Kingsleyluoxin的博客 Csdn博客. Ubuntu 20 04 Desktop Gui On Wsl 2 Surface Pro Useful Stuff. Available For Install Wsl Distribution Using Mand Learn It And Devops Daily. Run docker container on subsystem for linux 2. Installing Docker. While we could use Docker Desktop, we can also run the docker daemon (aka Docker Engine) directly within our WSL2 environment. It's faster, and takes up less system resources using this method. Bonus: This method also works for Windows on ARM users, which at the time of this writing, Docker Desktop is x86-64 only. Installing Docker Installing Docker with WSL2. First, start Ubuntu. Press the windows key and put in “Ubuntu” to get a suggestion, then click on it to launch the terminal. Then, run the following docker installation command. $ curl sh Allow docker to be used without sudo. $ sudo usermod -aG docker user.

Last June, the Docker team announced that they will be investing in getting Docker running with the Windows Subsystem for Linux (WSL). All of this is made possible with the recent changes to the architecture of WSL to run within a lightweight virtual machine (VM), which we talked about in an earlier blog post about WSL 2. Since this announcement, the Docker team has released a Technical Preview of Docker that includes support for running with WSL 2.

This article explains how the Docker Desktop technical preview works as well as how to use the Docker extension with the technical preview.

How it works

Install and Configure Ubuntu # install ubuntu from the store # open the ubuntu app # set username and password # close the ubuntu app wsl - set-version Ubuntu 2 Install Docker & Docker-compose on Ubuntu. WSL: Can't install docker on WSL 2, Ubuntu 18.04 Hot Network Questions What does the AP mean by a 'party split' regarding Biden's 'Build Back Better Plan'?

Install Docker On Ubuntu Wsl

This new Docker architecture works a lot like Visual Studio Code's WSL remote development support in that the Docker CLI running on the host machine executes commands within the Docker Integration Package, which runs on the remote WSL VM.

Image credit: Docker Engineering

DockerD runs directly within WSL so there's no need for the Hyper-V VM and all Linux containers run within the Linux userspace on Windows for improved performance and compatibility.

Getting set up

First some prerequisites:

  • Install Windows 10 Insider Preview build 18975 (Slow) or later for WSL 2.
  • Install Ubuntu from the Microsoft store.
  • Enable WSL 2 by following this guide.
  • Install the Remote - WSL extension for VS Code.
  • Install the Docker WSL 2 Technical Preview.

Once installed, Docker will recognize that you have WSL installed and prompt to enable WSL integration. You want to Enable WSL integration for this tutorial.

This option will allow you to access Docker Desktop via the Docker CLI directly from within your Linux distro.

If you have multiple Linux distros, make sure you only have WSL integration turned on for the correct one in your Docker settings:

With that configured, all commands will execute in the Linux context - this includes Docker commands run from PowerShell so running something like docker run mongo… will start a Linux container within the WSL VM.

Running the docker ps command over in WSL, you'll see the container as expected. Notice that the container ID matches.

Using VS Code

With this set up and running, you can install the VS Code Docker extension and access your containers. If you're already running WSL 2 and the Remote - WSL extension, this will help you get Docker integrated into your WSL workflow rather than switching contexts when you need containers. And because the Docker CLI's context is set to use DockerD in WSL, the extension will work with your containers regardless of whether you opened VS Code using the Remote - WSL extension.

Notice how in the screenshot below, I'm connected and working in WSL and still building/running containers without changing from my preferred environment (zsh in Ubuntu).

Theme: Noctis Sereno

I've personally noticed a vast improvement in container execution times using this configuration and each part of my typical development workflow remains the same. I'm also using the Remote - Containers extension within WSL for testing specific environments without setting things up directly on my machine.

We want your feedback

Keep in mind that you're using prerelease software and, while the Windows Insiders Slow ring is very stable, you may run into some issues. If you do find something that isn't working as expected, please open an issue via the Feedback tool in Windows. Any direct Docker issues or feedback can be logged in the Docker for Windows repo.

Happy Coding!

Matt Hernandez, VS Code Program Manager @fiveisprime

  • Trending Categories
  • Selected Reading
DockerUbuntuGo Programming

Docker is an open-source project that automates the deployment of application inside the software container. The container allows the developer to package up all project resources such as libraries, dependencies, assets etc. Docker is written in Go Programming language and is developed by Dotcloud. It is basically a container engine which uses the Linux Kernel features like namespaces and control groups to create containers on top of an operating system and automates the application deployment on the container.

Installing Docker

Before install Docker, it should required updated packages. To update the packages, use the following command –

Use the following command to add the GPG key for the official Docker repository to the system-

The sample output should be like this –

To add the Docker repository to APT sources, use the following command –

To update the package database with the Docker packages from the newly added repository, use the following command –

Make sure you are about to install from the Docker repository instead of the default Ubuntu repository. To verify it, use the following command –

The sample output should be like this –

Notice that, docker-engine is not installed,to install Docker-engine, use the following command –

The sample output should be like this –

To check whether docker is started or not, use the following command –

The sample output should be like this –

To start the Docker service, use the following command –

To view all the available subcommands of Docker, use the following command –

The sample output should be like this –

You can search for images available on Docker Hub by using the docker command with the search subcommand.

The sample output should be like this –

To see the images that have been downloaded to your computer, use the following command –

The sample output should be like this-

To run the Docker container, use the following command –

Install Docker On Ubuntu Wsl

Above command runs hello-word container. the sample output should be like this –

To listing Docker Containers, use the following command –

The sample output should be like this –

After this article, you will be able to understand – How To Install and Use Docker on Ubuntu 16.04 we will come up with more Linux based tricks and tips. Keep reading!

Install Docker On Ubuntu 20.04

  • Related Questions & Answers