简体   繁体   中英

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

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.

Set has no flag -g in bash. I do not know what you're trying to do with those flags, but if you want to set environment or shell variables, look at this .

For example, to set a variable use something like this: export ANT_HOME=/path/to/ant/dir

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM