Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

262
Views
Compilación de Dockerfile usando un script complejo de PowerShell en un contenedor de Windows

Estoy tratando de construir una imagen acoplable con un archivo acoplable que ejecuta powershell. El script de PowerShell incrustado ya se probó fuera del dockerfile, pero al ejecutar el dockerfile tiene errores.

Desde el archivo docker:

 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 \ "

Tuve el siguiente 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

El propósito de la secuencia de comandos es agregar contenido nuevo a una línea específica en el archivo de configuración

alguna idea de lo que está mal con la sintaxis?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Para resolver este problema, creo que debe agregar comillas dobles adicionales en la sección de su comando que reemplaza el nombre de la base de datos. Para mostrar un ejemplo, pegué un Dockerfile a continuación que produjo los resultados que esperaba según lo que entiendo que está tratando de lograr en la pregunta.

 FROM microsoft/windowsservercore COPY telegraf.conf C:\\telegraf\\telegraf.conf 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; \ "

Obviamente, espero que su Dockerfile se vea diferente, pero si toma el ejemplo que he usado anteriormente y agrega las comillas dobles adicionales alrededor de las que tiene dentro de su cadena, entonces debería encontrar que funciona como se esperaba.

Cualquier pregunta, hágamelo saber.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!