Insertar una instrucción de ejecución condicional dentro de un dockerfile
Estoy tratando de escribir un archivo docker que ejecutará un comando RUN para buscar una palabra en un paquete.archivo json y actuar sobre él:
Este es mi simple dockerfile:
FROM ubuntu:14.04
COPY package.json package.json
RUN if grep -q "grunt" package.json; then echo succeed fi
Como puede ver, solo quiero una declaración if simple, pero obtiene este error:
Step 2 : RUN if grep -q "grunt" package.json; then echo succeed fi
---> Running in af460df45239
/bin/sh: 1: Syntax error: end of file unexpected (expecting "fi")
INFO[0001] The command [/bin/sh -c if grep -q "grunt" package.json; then echo succeed fi] returned a non-zero code: 2
¿Cómo debo ejecutar mi comando? gracias.
29
1 answers
Al igual que al escribir en el shell, necesita una nueva línea o un punto y coma antes de fi
:
RUN if grep -q "grunt" package.json; then echo succeed; fi
add this ^
46
Author: jwodder,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-10 22:24:55
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-10 22:24:55