如何在码头组合文件中逃避$美元符号? [英] How can I escape a $ dollar sign in a docker compose file?
问题描述
我有一个YAML标量,当我尝试评估我的 docker-compose.yml
文件时,会抛出以下错误:
错误:
服务time_service中的环境选项的内插格式无效:$ {Time.now}
< blockquote>
YAML:
---
version:'2 '
services:
time_service:
build:。
环境:
TIME:$ {Time.now}
我可以保持与书面相同的字符串输出,但是避免将docker-compose解释为错误的字符串插值?
解决方案
它需要一个双重美元符号
$$
。 p>
所以我需要
$$ {Time.now}
,评估为$ {Time.now}
I have a YAML scalar that is throwing the following error when I try to evaluate my
docker-compose.yml
file:ERROR: Invalid interpolation format for "environment" option in service "time_service": "${Time.now}"
YAML:
--- version: '2' services: time_service: build: "." environment: TIME: "${Time.now}"
How can I maintain the same string output as written, but avoid having the docker-compose interpret it as faulty string interpolation?
解决方案Found the answer by copying the suggestion for
%
characters in this postIt requires a double dollar sign
$$
.So I needed
"$${Time.now}"
, which evaluates to"${Time.now}"
这篇关于如何在码头组合文件中逃避$美元符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!