Install Docker On Ubuntu Wsl

Environmental description

Environment: win10 enterprise + Ubuntu 18.04 lts [WSL]

Restart Ubuntu WSL; Once Ubuntu WSL is restarted, type docker run hello-world and press Enter. You should see a lengthy output that says somewhere in the middle, 'Hello from Docker!' Creating a bridge from WSL to Docker using a Linux VM and VirtualBox. This section assumes one is using VirtualBox and already has an Ubuntu 20.04 virtual machine. Mar 02, 2020 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.

Installing docker for windows in win10

Now docker has a special installation package for win10 professional system, and Hyper-V needs to be started.

Turn on Hyper-V

Procedures and functions

Turn windows features on or off

Select Hyper-V

Install docker for windows

The latest version of docker for windows

Install Docker On Ubuntu Wsl

Download address: https://docs.docker.com/v17.09/docker-for-windows/install/

Click Get docker for windows [stable] and download the version of windows:

After installation, docker will start automatically. A little whale icon will appear on the notice bar, which means docker is running.

Three icons will also appear at the table, as shown in the figure below:

We can execute it on the command linedocker version To see the version number,docker run hello-world To load the test image test.

If it doesn’t start, you can search docker in windows to start it:

After startup, you can also see the little whale icon on the notification bar:

Subsystem installation docker installation

No problem

Install Docker On Ubuntu Wsl

There is something wrong with the use

Explanation of official website

Official website explanation [solution]

[Cross Post] WSL Interoperability with Docker


Establish relay

Now with go installed, we can build relays. In the following command, make sure to replace it with your Windows user name:

We have now built a relay for windows, but we want it to be called from within WSL. To do this, we create a symbolic link. Make sure to replace with your Windows user name:

We will use socat to help enable relaying. Install socat, which is a tool that allows two-way flow of data between two points. Grab this package:

The last step

Install Docker On Ubuntu 20.04

With the installation of socat and the construction of executable files, we only need to string a few things together. We will make a shell script to activate our function. We will put it in the user’s home directory. To do this:

Open the file we created with your favorite text editor (such as VIM). Paste it into the file docker relay:


Save the file and close it. The docker relay script configures the docker pipeline to allow docker group access. To run as a normal user (without attaching ‘sudo’ to each docker command), add your WSL user to the docker group. In Ubuntu:

Test it!

Open a new WSL shell to ensure that your group membership is reset. Start the relay in the background:

Now run the docker command to test the waters. You should be welcomed by the same output as if you were running a command from windows (and note that you don’t need to add ‘sudo’ before the command!)

be careful

To start docker for windows in advance

Install Docker On Ubuntu Wsl Download

schematic diagram

Install Docker On Ubuntu Wsl2

There is a basic problem in making docker client run under WSL to communicate with docker for windows: WSL client understands IPC through UNIX socket, while docker for windows understands IPC through named pipe. That’s where socat and npiperalay.exe work – it’s the intermediary between the two disjoint forms of IPC. Socat understands how to communicate through UNIX sockets, npipereray understands how to communicate through named pipes. Both socat and npipereray know how to communicate through stdio, so they can communicate with each other.


Install Docker On Ubuntu Wsl Windows 10

The above is a tutorial of installing docker in Ubuntu (WSL), the win10 subsystem introduced by Xiaobian. I hope it can help you. If you have any questions, please leave me a message and Xiaobian will reply you in time. Thank you very much for your support to developer!
If you think this article is helpful to you, please reprint, please indicate the source, thank you!

Most Viewed Posts