Last active
August 29, 2015 14:14
-
-
Save ianblenke/9be295274cc83b3fad3e to your computer and use it in GitHub Desktop.
Preparing the DOCKER environment variables for fig to use, as pulled from a docker-machine config
This file contains hidden or 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
if which docker-machine > /dev/null 2>&1; then | |
export DOCKER_HOST="" | |
alias d="docker $(docker-machine config $(docker-machine ls -q | head -1))" | |
declare -a lines=( $(docker-machine config $(docker-machine ls -q | head -1)) ) | |
for (( i = 0; i < ${#lines[*]}; ++ i )) ; do | |
line="${lines[$i]}" | |
if [ "$line" = "--tls" ]; then | |
export DOCKER_TLS_VERIFY=true | |
fi | |
if echo "$line" | grep tlscert > /dev/null; then | |
docker_cert_file=$(echo "$line" | cut -d= -f2) | |
export DOCKER_CERT_PATH=$(dirname $docker_cert_file) | |
fi | |
if [ "$line" = "-H" ]; then | |
DOCKER_HOST="${lines[$i+1]}" | |
fi | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I put this in my dotfiles as ~/.bash_profile.d/docker-machine.sh so that it is sourced automagically.