WSL, Zsh, VSCode, Docker, NodeJS setup summary in 2020

Introduction

I got a new Surface, so I'd like to try WSL. It's just a summary, so it's for those who want to save the trouble of checking.

Installation of WSL and WSL2

WSL2 is required to use Docker Desktop WSL 2 backend, so I think you should upgrade to WSL2 from the beginning.

Official Manual (Japanese)

If you already have a WSL1 distribution, [the same document also describes how to upgrade](https://docs.microsoft.com/en-us/windows/wsl/install-win10#set-your- distribution-version-to-wsl-1-or-wsl-2).

Zsh Same procedure on Linux. Open WSL and install ZSH. (If you enter wsl in PowerShell etc., it will open)

sudo apt update
sudo apt install zsh

oh-my-zsh & autosuggestion

Oh-my-zsh

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

zsh-autosuggestion

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Open ~ / .zshrc in a text editor such as Vim and add the following in the file:

source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

Reload Zsh:

source ~/.zshrc

VSCode It works just by installing VS Code. Official Manual (Japanese) Extension for WSL

I made the Default Shell ZSH in the following way, but I'm not sure if I need it: In VS Code Ctrl + Shift + P → Enter" Select Default Shell "→ Select WSL (ZSH)

NodeJS The procedure is the same as installing NodeJS on Linux. Install using NVM.

nvm

Installation

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash

Add the following to ~ / .zshrc:

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

Reload Zsh:

source ~/.zshrc

NodeJS Open WSL. Install a specific version

nvm install x.x.x

or latest version

nvm install node

Docker (Docker Desktop WSL 2 backend) The requirements should be met according to the WSL and WSL2 manuals mentioned above. Just download the latest version of the installer and check the WSL2 checkbox during the installation.

Official Manual (English) (You don't have to look at it)

If you get the following error when typing docker in WSL:

The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

See https://docs.docker.com/docker-for-windows/wsl/ for details.

Check if you have Docker Desktop running on Windows or check the WSL version of your Linux Distribution, it will only work with WSL2.

Confirmation and upgrade method

Recommended Posts

WSL, Zsh, VSCode, Docker, NodeJS setup summary in 2020
WSL2 + VSCode + Docker development environment
How to use Docker in VSCode DevContainer
Try putting Docker in ubuntu on WSL
Edit Docker Container in VSCode multi-stage SSH Vagrant
Docker on Ubuntu18.04 on WSL2 and VSCode installation instructions
Docker basic summary
[Memo] docker summary
Docker command summary
Docker in LXD
[Docker] Command summary
Summary of frequently used commands in Rails and Docker
Create Chisel development environment with Windows10 + WSL2 + VScode + Docker