user2798694 user2798694 - 3 months ago 27
Linux Question

Can't set docker-machine environment variables bash

I' using bash 4.3 and I can't export or set docker-machine environment variables

bash-4.3$ docker-machine env default
set -gx DOCKER_TLS_VERIFY "1";
set -gx DOCKER_HOST "tcp://192.168.99.100:2376";
set -gx DOCKER_CERT_PATH "/Users/ofolorunso/.docker/machine/machines/default";
set -gx DOCKER_MACHINE_NAME "default";
# Run this command to configure your shell:
# eval (docker-machine env default)


Apparently bash doesn't recognize the
g
flag

bash-4.3$ eval "$(docker-machine env default)"
bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
bash: set: -g: invalid option
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]


I should note that my machine's default shell is
fish

Answer

Have you tried forcing bash with the --shell option?

docker-machine env --shell bash default
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST "tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH "/Users/ofolorunso/.docker/machine/machines/default"
export DOCKER_MACHINE_NAME="default"

Env variables are set with set -gx in fish and with export in bash.