Recently I installed Docker on Windows Subsystem for Linux (WSL). As well known, Docker does not work in Windows 10 Home without 3rd party virtualization tools such as virtual box. I found, on WSL (especially Ubuntu 18.04), running Docker is possible. There are a lot of articles about it. In spite of this situation, I had many trouble installing. So, in this article I write about how I installed Docker on my WSL environment successfully.
My Environment
- Windows 10 Home
- Ubuntu 18.04 (WSL)
Some articles says that Docker does not work in Ubuntu 18.04, install Ubuntu 16.04 from Microsoft Store, but it is not correct. It is unnecessary that your WSL environment is the Ubuntu 16.04.
Install
Many articles says that Docker-ce does not work because that has newer docker therefore we should install Docker.io for getting older version. But Recently, Docker.io also has newer version.
So, we need to install Docker with specifying the version to get docker works in WSL.
curl -O https://download.docker.com/linux/debian/dists/stretch/pool/stable/amd64/docker-ce_17.09.0~ce-0~debian_amd64.deb
sudo apt install libltdl7 -y
sudo dpkg -i docker-ce_17.09.0\~ce-0\~debian_amd64.deb
Start Docker
After installing Docker-ce, restart the WSL. Be careful there is cases that the WSL process alive even if closing window, if so, find processes and kill them manually or restart Windows.
Next, let’s start docker. Open WSL with admin and enter
sudo service docker start
# * Starting Docker: docker [ OK ]
service docker status
# * Docker is running
If docker works well, you can see the message above. Next, try hello-world container.
docker pull hello-world
# Using default tag: latest
# latest: Pulling from library/hello-world
# 1b930d010525: Pull complete # Digest: sha256:d1668a9a1f5b42ed3f46b70b9cb7c88fd8bdc8a2d73509bb0041cf436018fbf5
# Status: Downloaded newer image for hello-world:latest
# docker.io/library/hello-world:latestdocker images
# REPOSITORY TAG IMAGE ID CREATED SIZE
# hello-world latest fce289e99eb9 12 months ago 1.84kBdocker run hello-world
If you can see “Hello from Docker!” message, it succeeded in. Congratulation!