以下在docker中可以正常工作:
docker run -i -t -rm -e a="hello world" b=world ubuntu /bin/bash
ENV_VARS='-e a=helloworld b=world'
docker run -i -t -rm $ENV_VARS ubuntu /bin/bash
ENV_VARS='-e a="hello world" b=world'
docker run -i -t -rm $ENV_VARS ubuntu /bin/bash
Unable to find image 'world"' (tag: latest) locally
2014/01/15 16:28:40 Invalid repository name (world"), only [a-z0-9-_.] are allowed
Bash数组旨在解决此类问题
第一步是声明数组:
docker_env=(-e "a=hello world" "b=world")
docker_env+=("c=foo bar")
docker run -i -t -rm "${docker_env[@]}" ubuntu /bin/bash
关于bash - 我如何使用bash将环境传递给docker?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21151216/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |