简体   繁体   English

无法设置docker-machine环境变量bash

[英]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环境变量

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不识别g标志

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 我应该注意到我机器的默认外壳是fish

Have you tried forcing bash with the --shell option? 您是否尝试过使用--shell选项强制bash?

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. env变量在fish中set -gx ,在bash中set -gxexport

Set has no flag -g in bash. Set在bash中没有标志-g。 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 . 我不知道你要对这些标志做什么,但是如果你想设置环境或shell变量,请看看这个

For example, to set a variable use something like this: export ANT_HOME=/path/to/ant/dir 例如,要设置变量,请使用以下内容: export ANT_HOME=/path/to/ant/dir

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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