简体   繁体   English

是否可以评估docker env_file中的shell命令(在主机上执行)?

[英]Is it possible to evaluate shell commands (to be executed on the host) inside a docker env_file?

I run a docker container with docker run --env-file envfile image . 我使用docker run --env-file envfile image容器。 envfile contains environment variables like LISTEN=localhost:12345 , SSH_USER=jannis , etc. envfile包含环境变量,例如LISTEN=localhost:12345SSH_USER=jannis等。

I tried adding a variable as follows: SSH_PRIVATE_KEY=`cat ~/.ssh/id_rsa` . 我尝试如下添加变量: SSH_PRIVATE_KEY=`cat ~/.ssh/id_rsa` I expected Docker to execute the command in $() on the host machine and set the variable to its output; 我希望Docker 在主机上的 $()执行命令,并将变量设置为其输出; however, Docker just set the variable literally. 但是,Docker只是从字面上设置变量。 Is there a way to do this? 有没有办法做到这一点?

在编写此代码时,我认为我可以让执行的Shell为我完成工作,然后传递--env SSH_PRIVATE_KEY=`cat ~/.ssh/id_rsa`

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

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