如何在码头组合文件中逃避$美元符号? [英] How can I escape a $ dollar sign in a docker compose file?

查看:838
本文介绍了如何在码头组合文件中逃避$美元符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个YAML标量,当我尝试评估我的 docker-compose.yml 文件时,会抛出以下错误:


错误:
服务time_service中的环境选项的内插格式无效:$ {Time.now}


< blockquote>

YAML:

  --- 
version:'2 '
services:
time_service:
build:。
环境:
TIME:$ {Time.now}

我可以保持与书面相同的字符串输出,但是避免将docker-compose解释为错误的字符串插值?

解决方案

找到在%字符的建议的答案, in-yaml>这篇文章



它需要一个双重美元符号 $$ 。 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 post

It requires a double dollar sign $$.

So I needed "$${Time.now}", which evaluates to "${Time.now}"

这篇关于如何在码头组合文件中逃避$美元符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆