LoginSignup
1
2

More than 5 years have passed since last update.

Installation of WSL on Windows 10 Pro

Last updated at Posted at 2019-03-11

Setting of WSL

This article was written in 2019-03-09.

Please note that version of Windows, WSL, and other installed applications on Ubuntu may differ when you are reading this article; there is no guarantee to success those installation.

Install Ubuntu 18.04 from Windows Store

Install Ubuntu 18.04 by GUI. Google it for instructions.

Windows settings

Install VcXsrv from https://sourceforge.net/projects/vcxsrv/
see installation process

bash on Ubuntu

start bash by clicking Windows' start menu -> Ubuntu 18.04. Then,

$ sudo apt update && sudo apt upgrade -y

X11

$ cat << EOF >> .bashrc
export DISPLAY=localhost:0.0
export LIBGL_ALWAYS_INDIRECT=1
EOF

# check
$ source .bashrc # need reload
$ sudo apt install x11-apps
# check launch
$ xeyes

Then install other x11s

$ sudo apt install x11-utils x11-xserver-utils dbus-x11

Language

Set Japanese.

$ sudo apt install language-pack-ja
$ sudo update-locale LANG=ja_JP.UTF-8
# check
$ echo $LANG
$ locale

Timezone

# selected Asia/Tokyo
$ sudo dpkg-reconfigure tzdata

Japanese input on Xapp

I tried to install ibus-mozc, but it didn't work. So decided to use uim-anthy. See fcitx-mozc installation at https://qiita.com/maromaro3721/items/be8ce6e3cec4cbcdac00

reference: https://tobubiyori.blogspot.com/2017/04/creaters-update-ubuntu-1604bash-on.html

uim-anthy

$ sudo apt install leafpad uim uim-xim uim-anthy
# font for x11
# $ sudo apt install fonts-ipafont
$ sudo apt install fonts-noto-cjk fonts-noto-color-emoji
# check Ctrl-Space or 半角/全角 ボタン
$ echo << EOF >> .bashrc
# for uim input
export XIM=uim
export XMODIFIERS=@im=uim
export UIM_CANDWIN_PROG=uim-candwin-gtk
# export UIM_CANDWIN_PROG=uim-candwin-qt
export GTK_IM_MODULE=uim
export QT_IM_MODULE=uim
#
if [ $SHLVL -eq 1 ]; then
          uim-xim &
fi
EOF

# for Japanese keyboard
$ echo << EOF >> .uim
(define default-im-name 'anthy)
(define-key generic-on-key? '("Henkan_Mode" "zenkaku-hankaku" "<Control> " "<Control>\\"))
(define-key generic-off-key? '("Muhenkan" "zenkaku-hankaku" "<Control> " "<Control>\\"))
(define-key anthy-extend-segment-key? '("<Control>o"))
(define-key anthy-shrink-segment-key? '("<Control>i"))
EOF

$ source .bashrc
$ leafpad

Desktop -> LXDE

$ sudo apt install lxde
$ startlxde

or

$ sudo apt install lxpanel
$ lxpanel --profile LXDE &

Change default directory names from Japanese to English like デスクトップ -> desktop

sudo apt install xdg-user-dirs-gtk
LANG=C xdg-user-dirs-gtk-update

Intellij

Note: snap command is not working on WSL now.

Interacting with snapd is not yet supported on Windows Subsystem for Linux.
This command has been left available for documentation purposes only.

Unofficial Debian / Ubuntu packages of IntelliJ IDEA from JetBrains.
https://launchpad.net/~mmk2410/+archive/ubuntu/intellij-idea
Note: It is your responsibility to use unofficial installer

sudo add-apt-repository ppa:mmk2410/intellij-idea
sudo apt update
sudo apt install intellij-idea-community

IDE -> プログラミング -> IntelliJ IDEA Community Edition
(/usr/share/applications/intellij-idea-community.desktop)

docker on WSL

Note: Ubuntu 18.04 on WSL with Windows 10 1803 does not support latest docker of version 18.
You need to update windows 10 from 1803 to 1809.
(https://www.microsoft.com/ja-jp/software-download/windows10)

reference: http://j-levia.hatenablog.jp/entry/2019/01/02/234032

$ uname -a
Linux *** 4.4.0-17763-Microsoft #253-Microsoft Mon Dec 31 17:49:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"

The below operation is bad installation, showing only for demostrate purpose

# install (fails)
sudo apt update && sudo apt upgrade
sudo apt install -y docker.io
sudo apt-get install -y docker.io
# restart bash as Admin priviledge (meaning cmd or other console runs as Admin and typo `bash`)
sudo usermod -aG docker $USER
sudo cgroupfs-mount
sudo service docker start
docker run hello-world

Error occurs. Need to downgrade (see https://github.com/docker/for-linux/issues/591)

$ docker run hello-world
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "process_linux.go:301: running exec setns process for init caused \"exit status 23\"": unknown.
ERRO[0009] error waiting for container: context canceled

Install docker-ce, not docker.io
(https://www.quora.com/What-is-the-difference-between-docker-engine-and-docker-io-packages)

# https://docs.docker.com/install/linux/docker-ce/ubuntu/
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs)  stable"
# check previous version
apt-cache madison docker-ce
sudo apt-get install docker-ce=18.06.1~ce~3-0~ubuntu # this version works

# service
sudo usermod -aG docker $USER

sudo cgroupfs-mount
sudo service docker start
docker version

If docker service is resistered, you do not need run bash as Admin.
Restart your windows shell as normal user.

$ docker run -it --rm hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

That's all.

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2