Last active
May 14, 2020 17:17
-
-
Save jwilson8767/00a46f5ca63327d5bfd802f87b702c8d to your computer and use it in GitHub Desktop.
Docker Toolbox for Windows and Windows Subsystem for Linux (aka Bash on Windows)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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) | |
# | |
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 | |
#Set docker-machine to run on terminal start. | |
cat >> ~/.bashrc << 'EOM' | |
# Start the docker machine | |
export VBOX_MSI_INSTALL_PATH='/c/Program Files/Oracle/VirtualBox/' | |
pushd '/c/Program Files/Docker Toolbox/' > /dev/null | |
./start.sh exit | |
# Get env variables from docker-machine, convert paths, ignore comments, and strip double quotes. | |
$(./docker-machine.exe env --shell bash | sed 's/C:/\/c/' | sed 's/\\/\//g' | sed 's:#.*$::g' | sed 's/"//g' ) | |
popd > /dev/null | |
# Change /mnt/c/ to /c/ in current working directory path | |
cd $(pwd | sed 's/\/mnt\/c\//\/c\//') | |
EOM |
Unfortunately, start.sh uses a windows path to docker-machine.exe. I fixed it locally to use which
to find the executable but then that exposed another issue: you cannot run docker-machine.exe commands without the variables set by docker-machine.exe --shell bash
. So you can't run the command that sets the variables that you need to run the command.
source <(docker-machine.exe env default --shell bash | sed 's?\\?/?g;s?C:/?/mnt/c/?g')
run this before docker-compose.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A recent commit in docker toolbox breaks this. Two changes in this commit are problematic.
export DOCKER_TOOLBOX_INSTALL_PATH='/c/Program Files/Docker Toolbox'
before calling./start.sh exit
.