Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- envsubst字面上看是环境变量替换的意思,实际功能也如此。
- envsubst从输入中读取文本并输出,如果遇到环境变量,会解析环境变量。
- ```shell
- localhost:shell wangwei$ export hello=1
- localhost:shell wangwei$ envsubst
- hello$hello
- hello1
- ```
- 直接在shell中输入envsubst会读标准输入写入标准输出,因此输入hello$hello被解析成hello1。常用的方式是通过模板生成文件:
- ```shell
- localhost:shell wangwei$ export x=2
- localhost:shell wangwei$ export y=5
- localhost:shell wangwei$ echo $x+$y > template.txt
- localhost:shell wangwei$ envsubst < template.txt > conf.txt
- ```
- conf.txt中的内容:
- ```shell
- 2+5
- ```
- 在编写Dockerfile的时候常常使用envsubst这个命令。
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement