Install Docker on Windows Subsystem for Linux

From JMK Wiki
Revision as of 16:13, 3 June 2018 by Gabor Hudiczius (talk | contribs) (initial version)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Install Docker

Note: based on


Install required packages:

root@localhost ~ # apt install curl apt-transport-https

Add the docker repository to the sources.list configuration:

root@localhost ~ # echo "deb stretch stable" > /etc/apt/sources.list.d/docker.list

Optionally the edge channel can be used for more recent version:

root@localhost ~ # echo "deb stretch edge" > /etc/apt/sources.list.d/docker.list

Download and add the private key for the repository:

root@localhost ~ # curl -fsSL | apt-key add -

Verify the private key:

root@localhost ~ # apt-key fingerprint 0EBFCD88

Update the list of available packages:

root@localhost ~ # apt update

Install Docker

Install docker:

root@localhost ~ # apt install docker-ce

Verify Docker version:

user@localhost ~ $ docker -v

Add the user to the docker group so no root privileges are needed to create and start containers (use the actual username instead of <USERNAME>):

root@localhost ~ # usermod -aG docker <USERNAME>

This will only take effect after the user logged out and then logged in again.

Set the docker host for the user:

user@localhost ~ $ source ~/.bashrc

Verify if docker works:

user@localhost ~ $ docker ps

Install docker-compose

While docker compose can be installed from the Debian repository it is an outdated version and it is better to install via pip (the python package manager):

root@localhost ~ # apt install python-pip
root@localhost ~ # pip install docker-compose

Verify docker-compose version:

root@localhost ~ # docker-compose -v

Fix docker mount points

For a more detailed explanation visit

Windows 10 version 1803

root@localhost ~ # echo -e "[automount]\nroot = /\noptions = metadata" > /etc/wsl.conf

A WSL restart is required

Windows 10 version 1709

root@localhost ~ # mkdir /c
root@localhost ~ # mount --bind /mnt/c /c