Skip to content

Instantly share code, notes, and snippets.

@salaros
Last active January 8, 2019 08:20
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 salaros/7cc3f768dcfdc58c43585a7232579b59 to your computer and use it in GitHub Desktop.
Save salaros/7cc3f768dcfdc58c43585a7232579b59 to your computer and use it in GitHub Desktop.
Make Docker work on Ubuntu WSL (Windows Subsystem for Linux)
[automount]
root = /
options = "metadata"
#!/usr/bin/env bash
if [[ ! -f /etc/apt/sources.list.d/docker.list ]]; then
echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu ${OS_RELEASE} stable" | \
sudo tee /etc/apt/sources.list.d/docker.list;
curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x7EA0A9C3F273FCD8" | sudo apt-key add;
fi
sudo apt update && sudo apt install docker-compose docker-ce -qy
sudo usermod -a -G docker $USER
if [ -f ~/.exports ]; then
EXPORTS_FILE=~/.exports
else
EXPORTS_FILE=~/.bashrc
fi
if [ -z $(grep DOCKER_HOST ${EXPORTS_FILE}) ]; then
echo -e "# Use Docker daemon on WSL
if grep -q Microsoft /proc/version; then
export DOCKER_HOST=tcp://localhost:2375
" >> ${EXPORTS_FILE} && ${EXPORTS_FILE}
fi

Configure Docker for Windows

In the general settings, you’ll want to expose the daemon without TLS. This step is necessary so that the daemon listens on a TCP endpoint. If you don’t do this then you won’t be able to connect from WSL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment