[LINUX] What I did before installing Docker for Windows

For the time being, I will leave what I did roughly

--Windows update --Installing Ubuntu from Microsoft Store --Upgrade to WLS2 --Installing Docker for Windows

Windows version check

Enter ** run **, ** winver ** in [Win + R] image.png At this stage, ** Docker for Windows cannot be installed if the version is ** 19018 or lower **. ** **

Windows update

That's why I will update Windows itself. Windows 10 May 2020 Update

** Download the update from the [Update now] ** button. image.png

The ** Windows10Upgrade9252.exe ** file will be downloaded, click it to launch it.

I forgot to capture the progress on the way, but it will be completed in about 30 minutes after starting, and you will be asked to restart. image.png

When I checked the version after rebooting, it became ** 19041 **

image.png

Install Ubuntu from Microsoft Store

Originally I haven't used WSL properly after a long time using Windows, so even if I try to start wsl, it will be as follows. image.png

So, install Linux (Ubuntu) from the Microsoft Store.

Start the Microsoft Store. image.png

Select Ubuntu 20.04.LTS. It's okay to have your favorite Linux here. image.png

Click Install. image.png

Click the launch button when the installation is complete. image.png

When you start it, a terminal will open, so set the username and password. image.png

This is the end of Ubuntu settings. image.png

Upgrade to WLS2

Windows function check and update

Start PowerShell as ** Administrator **. image.png

You can check the function of Windows with the following command

dism.exe /online /get-features

Check if the following two are ** enabled ** when executing the command

Function name: Microsoft-Windows-Subsystem-Linux
Status:Effectiveness

Function name: VirtualMachinePlatform
Status:Effectiveness

If not, enable it with the following command

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Linux kernel update

Check your installed Linux distribution.

wsl --list --verbose
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         1

Since it is Version 1 now, I will raise it to Version 2 with a command, but if I do it as it is ** Kernel component updates are required to run WSL 2 ** I will be told, so I will update the Linux cannel.

Access the following page to download the package. Update WSL 2 Linux Kernel image.png

The ** wsl_update_x64 ** file will be downloaded, click it to launch it.

image.png

Press [Next]

image.png

Press [Finishi] to complete.

Set Linux distribution to WSL2

Update Ubuntu to WSL2 with the following command

wsl --set-version Ubuntu-20.04 2

Check the distribution.

wsl --list --verbose
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2

It has changed.

Set WSL2 as default

Change the default version from WSL to WSL2

wsl --set-default-version 2

Install Docker for Windows

Originally I wanted to do this. It's been a detour, but it's coming to install.

Docker Desktop for Windows

The ** Docker Desktop Installer ** file will be downloaded, click it to launch it.

image.png

** [OK] ** to proceed

image.png

Installation will proceed

image.png

Done, log out with ** [Close and log out] ** At this time, it will take a reboot

After restarting, it was the setting screen of Docker for windows, but honestly I only use Docker commands, so I skipped it.

For the time being, it is resident in the following location during startup, and the screen can be opened from the Dashboard. image.png

Summary

It was long anyway. I've heard that Docker for Windows is annoying, but so far ... However, I think it's better that Docker's execution environment is Ubuntu after WSL2.

So, I will do what I really wanted to do.

2020/07/28 postscript

I'm surprised that there are more people who have seen it than I expected. Thank you for the rough content I will add something that I was a little worried about while using it.

WSL2 restart

There are quite a few timings to restart. For example, the time of launching ** Ubuntu may be quite different. ** ** This is already on the Issue, so it will be cured soon.

There are various ways to fix this time lag, but the quickest way is to restart, so here is the restart command.

wsl.exe --shutdown

** Run with elevated Powershell. ** **

Memory-hungry problem

As you can see in the task manager, a task called ** Vmmem ** eats up memory. This issue also has Issue.

I think it will be fixed soon, but Issue has suggested a workaround now.

  1. Reboot
  2. WSL memory upper limit setting
  3. Free memory with command

For the time being, 1 is omitted, and the certainty is high. Use the other two at ** just to try and see **.

2. WSL memory upper limit setting

*** Create a file called *** .wslconfig in the Windows user directory (C: \ Users \ ). After writing the following settings in it, restart.

[wsl2]
memory=2GB
swap=16GB
localhostForwarding=true
hisayuki@DESKTOP:~/develop/annowork_devlop$ free -h
              total        used        free      shared  buff/cache   available
Mem:          1.9Gi       1.7Gi        63Mi       0.0Ki       169Mi        92Mi
Swap:          16Gi       326Mi        15Gi

The effect is quite sparse when looking at the Issue, but this is also a solid effect. This time it is suppressed by 2G, and the task manager side is not at the moment more than 2G.

3. Free memory with command

Use the following command to clear unnecessary cache and free memory.

echo "sync && echo 3 > /proc/sys/vm/drop_caches" | sudo sh

This is also a feeling, so there is no definite factor. In addition, if you run Docker for windows on Ubuntu or actually run Container, it will increase after all.

Recommended Posts

What I did before installing Docker for Windows
[Note] Procedures for installing Ubuntu on Windows 10
What I did to save Python memory
[Python] What I did to do Unit Test
[For beginners] What to do after installing Anaconda
What I did when updating from Python 2.6 to 2.7
Installing TensorFlow on Windows Easy for Python beginners
What I did before installing Docker for Windows
[At Coder] What I did to reach the green rank in Python
What I did with a Python array
What I always add to my ~ / .bashrc
What I did to save Python memory
I started Docker
What I got into Python for the first time
What I did when I stumbled on a Django tutorial
A memo of installing Chainer 1.5 for GPU on Windows
I built a Wheel for Windows using Github Actions
What I did to ssh to the VPS Ubuntu environment
What I did to get started with Linux commands