且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

exec docker运行时docker中的环境变量

更新时间:2023-09-18 21:40:52

echo $HOME进行评估,因为您没有转换为bash正确的语法.它是Linux,因此您需要单引号.

echo $HOME is being evaluated on your host because you haven't got the syntax of the switch to bash correct. It's Linux so you need single quotes.

尝试将单引号替换为双引号.

Try replacing your double quotes with single quotes.

例如这就是我得到的:

bash-3.2$  docker run ubuntu /bin/bash -c 'echo $HOME'
/root