Install Docker on Windows Subsystem for Linux
Install Docker
Note: based on https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly.
Prerequisites
Install required packages:
root@localhost ~ # apt install curl apt-transport-httpsAdd the docker repository to the sources.list configuration:
root@localhost ~ # echo "deb https://download.docker.com/linux/debian stretch stable" > /etc/apt/sources.list.d/docker.listOptionally the edge channel can be used for more recent version:
root@localhost ~ # echo "deb https://download.docker.com/linux/debian stretch edge" > /etc/apt/sources.list.d/docker.listDownload and add the private key for the repository:
root@localhost ~ # curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -Verify the private key:
root@localhost ~ # apt-key fingerprint 0EBFCD88Update the list of available packages:
root@localhost ~ # apt updateInstall Docker
Install docker:
root@localhost ~ # apt install docker-ceVerify Docker version:
user@localhost ~ $ docker -vAdd 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 ~ $ echo "export DOCKER_HOST=tcp://127.0.0.1:2375" >> ~/.bashrcuser@localhost ~ $ source ~/.bashrcVerify if docker works:
user@localhost ~ $ docker psuser@localhost ~ $ docker run busybox uname -aInstall docker-compose
Like AWS CLI, docker compose can be installed from the Debian repository it is an outdated version and it is better to install via pip:
root@localhost ~ # pip install docker-composeVerify docker-compose version:
user@localhost ~ $ docker-compose -vFix docker mount points
For a more detailed explanation visit https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly.
Windows 10 version 1803
root@localhost ~ # echo -e "[automount]\nroot = /\noptions = metadata" > /etc/wsl.confA WSL restart is required
Windows 10 version 1709
root@localhost ~ # mkdir /croot@localhost ~ # mount --bind /mnt/c /c