Goal of this article
- Installing WSL2
- Installing Docker
- Installing docker-compose
Development environment to be built
- wsl2(Ubuntu20.0.4)
- Docker 20.10.1
- docker-compose 1.27.4
Do not use “Docker for Windows”. Docker is installed on WSL2.
Installing WSL2
Starting Powershell
First, let’s start Powershell. Press the windows key and search for “Powershell”.
Right-click on “Powershell” with your mouse. Click on “Run as administrator”.
Then the application will be launched as shown in the image below.
Enable WSL2
Execute the following command in Powershell.
Enable the “Windows Subsystem for Linux”.
PS C:\Windows\system32> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Activate the “Virtual Machine Platform” option.
PS C:\Windows\system32> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
When you’re done here, reboot your computer.
Install “Ubuntu 20.04” from Microsoft Store.
Open the Microsoft Store and search for “Ubuntu”.
Select “Ubuntu 20.04 LTS” and install it.
Press the “Launch” button in the picture to open the terminal and wait for a while.
You will then be asked for a user name. This is optional, but in this article, we will specify “user”.
Next, you will be asked for a password. Please enter your own password.
Update to WSL2
Download the updated Linux kernel.
Click here to download “wsl_update_x64.msi”.
Run the installer to install the latest kernel.
Run the following command in Powershell to confirm that the current wsl version is 1.
PS C:\Windows\system32> wsl --list --verbose NAME STATE VERSION * Ubuntu-20.04 Running 1
PS C:\Windows\system32> wsl --set-default-version 2
Execute the following command.
PS C:\Windows\system32> wsl --set-version Ubuntu-20.04 2
If you run the confirmation command again, you will see that the version is now 2.
PS C:\Windows\system32> wsl --list --verbose NAME STATE VERSION * Ubuntu-20.04 Stopped 2
WSL2 build complete!
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 https://get.docker.com | sh
Allow docker to be used without sudo.
$ sudo usermod -aG docker user
If the version is checked and displayed as shown below, you have succeeded.
$ docker --version Docker version 20.10.1, build 831ebea
Install “apt-transport-https”, which enables the transfer of files from HTTPS sites.
$ sudo apt install apt-transport-https
Download the GPG key for the “systemd-genie” package repository.
$ sudo wget -O /etc/apt/trusted.gpg.d/wsl-transdebian.gpg https://arkane-systems.github.io/wsl-transdebian/apt/wsl-transdebian.gpg
Create a new file “/etc/apt/sources.list.d/wsl-transdebian.list” with vi command and add the following two lines.
$ sudo vi /etc/apt/sources.list.d/wsl-transdebian.list
# wsl-transdebian.list
deb https://arkane-systems.github.io/wsl-transdebian/apt/ focal main
deb-src https://arkane-systems.github.io/wsl-transdebian/apt/ focal main
Install genie.
$ sudo apt update
$ sudo apt install systemd-genie
Restart WSL, and if you can run genie -s, you are good to go.
You will now see “username@hostname-wsl”.
$ genie -s
Installing docker-compose in WSL2
Run the docker-compose installation command.
You can also change the 1.27.4 part to any version you want.
$ sudo curl -L https://github.com/docker/compose/releases/download/1.27.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
Next, grant execution privileges to the docker-compose command using the following command.
$ sudo chmod +x /usr/local/bin/docker-compose
If you can see the version, you’ve succeeded!
$ docker-compose --version docker-compose version 1.27.4, build 40524192
コメント