Skip to content

Instantly share code, notes, and snippets.

@carlin-q-scott
Forked from jwilson8767/install_WSL_docker.sh
Last active November 17, 2018 21:49
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 carlin-q-scott/a91d6cb0065322a5e6d85961a9fc1b1a to your computer and use it in GitHub Desktop.
Save carlin-q-scott/a91d6cb0065322a5e6d85961a9fc1b1a to your computer and use it in GitHub Desktop.
Docker or Docker Toolbox for Windows and Windows Subsystem for Linux (aka Bash on Windows)
#!/bin/sh
exec socat UNIX-LISTEN:/var/run/docker.sock,fork,group=docker,umask=007 EXEC:"npiperelay.exe -ep -s //./pipe/docker_engine",nofork
#!/bin/env bash
# This script installs and configures WSL to work with Docker (Toolbox) for Windows.
# 1. Install WSL (check out [bowinstaller](https://github.com/xezpeleta/bowinstaller) for programmatic installation.
# 2. Run the contents of this script in Bash. (copy and paste works fine, no need to save)
#
# options: 4win (default) and toolbox
dockerType=$(1:4win)
sudo -sEH << 'EOM'
# Install the docker client and docker-compose
apt-get update && apt-get install -y curl ca-certificates
curl -sSL https://get.docker.com/ | sh
curl -L "https://github.com/docker/compose/releases/download/1.11.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# Add the current user to the docker group.
usermod -aG docker $(id -un)
# Symlink /c/ to /mnt/c/ as Docker Toolbox is expects /c/ path mappings.
[[ ! -e /c/ ]] && ln -s /mnt/c /
EOM
# configure docker environment
if '$dockerType' = 'toolbox'; then
cat >> ~/.bashrc << 'EOM'
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/c/Users/$USER/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
# Change /mnt/c/ to /c/ in current working directory path
cd $(pwd | sed 's/\/mnt\/c\//\/c\//')
EOM
else
wget -O ~/docker-relay.sh https://gist.github.com/carlin-q-scott/a91d6cb0065322a5e6d85961a9fc1b1a/raw/83c01a16c146c8178bfb6e0bf20d8af262ab4ea0/docker-relay.sh
cat >> ~/.bashrc << 'EOM'
[[ ! -e /var/run/docker.sock ]] && sudo ~/docker-relay.sh
# Change /mnt/c/ to /c/ in current working directory path
cd $(pwd | sed 's/\/mnt\/c\//\/c\//')
EOM
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment