Skip to content

Instantly share code, notes, and snippets.

@leobrines
Last active April 29, 2020 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leobrines/362ee29da66061a934dac16e8492d788 to your computer and use it in GitHub Desktop.
Save leobrines/362ee29da66061a934dac16e8492d788 to your computer and use it in GitHub Desktop.
Install docker on Windows Subsystem for Linux (execute as root)
# You must exec as root
# Sources:
# https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly
# https://nickjanetakis.com/blog/docker-tip-73-connecting-to-a-remote-docker-daemon
# https://medium.com/faun/docker-running-seamlessly-in-windows-subsystem-linux-6ef8412377aa
# https://medium.com/@sebagomez/installing-the-docker-client-on-ubuntus-windows-subsystem-for-linux-612b392a44c4
apt update
apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common
# Fix IPC connection fail (https://github.com/microsoft/WSL/issues/5125#issuecomment-619350931)
add-apt-repository ppa:rafaeldtinoco/lp1871129
apt update
apt install libc6=2.31-0ubuntu8+lp1871129~1 libc6-dev=2.31-0ubuntu8+lp1871129~1 libc-dev-bin=2.31-0ubuntu8+lp1871129~1
apt-mark hold libc6
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# For focal dont work, so use bionic
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
apt update
apt-cache policy docker-ce
apt install docker-ce
# Auto startup
echo "#!/usr/bin/env bash
sudo cgroupfs-mount
sudo service docker start
" > /usr/local/sbin/start_docker.sh
# Allow your user to access the Docker CLI without needing root access.
sudo usermod -aG docker $USER
chmod +x /usr/local/sbin/start_docker.sh
/bin/sh /usr/local/sbin/start_docker.sh
echo "export DOCKER_HOST=localhost:2375" >> ~/.bashrc && source ~/.bashrc
docker images
service docker status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment