我正在尝试使用运行 powershell 的 dockerfile 构建 docker 映像。嵌入式 powershell 脚本已经在 dockerfile 之外进行了测试,但是在运行 dockerfile 时会出现错误。
从码头文件:
RUN powershell -NoProfile -Command " \
$lines = (Get-Content c:\telegraf\telegraf.conf).replace('http://localhost:8086', 'http://publichost.com:8086'); \
Set-Content c:\telegraf\telegraf.conf $lines; \
$lines = (Get-Content c:\telegraf\telegraf.conf).replace('database = "telegraf"', 'database = "qa"'); \
Set-Content c:\telegraf\telegraf.conf $lines \
"
我收到以下错误:
At line:1 char:97
+ ... egraf.conf; $pos = [array]::indexof($lines, $lines -match global_ ...
+ ~
You must provide a value expression following the '-match' operator.
At line:1 char:97
+ ... egraf.conf; $pos = [array]::indexof($lines, $lines -match global_ ...
+ ~
Missing ')' in method call.
At line:1 char:98
+ ... $pos = [array]::indexof($lines, $lines -match global_tags); $ ...
+ ~~~~~~~~~~~
Unexpected token 'global_tags' in expression or statement.
At line:1 char:109
+ ... $pos = [array]::indexof($lines, $lines -match global_tags); $l ...
+ ~
Unexpected token ')' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : ExpectedValueExpression
该脚本的目的是将新内容添加到配置文件的特定行
知道语法有什么问题吗?