我正在尝试编写一个docker文件,该文件将运行RUN命令以在package.json文件中搜索单词并对其执行操作:
这是我简单的dockerfile:
FROM ubuntu:14.04 COPY package.json package.json RUN if grep -q "grunt" package.json; then echo succeed fi
如您所见,我只想要一个简单的if语句,但它得到此错误:
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
我应该如何运行命令?谢谢。
就像在shell上键入内容一样,您需要在前面加上换行符或分号fi:
fi
RUN if grep -q "grunt" package.json; then echo succeed; fi add this ^