I am trying to build a docker image with a dockerfile that runs powershell. The embedded powershell script has already been tested outside of the dockerfile, but when running the dockerfile it has errors.
From docker file:
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 \
"
I got the following error:
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
The purpose of the script is to add new content to specific line on the config file
any idea what wrong with the syntax?