我想使用RUN指令在Dockerfile中编写以下命令:
cat > /etc/myconfig.conf << EOL
line 1, ${kernel}
line 2,
line 3, ${distro}
line 4
line 5
EOL
我是按照以下方式做的,但似乎错了
RUN cat > /etc/myconfig.conf << EOL \
line 1, ${kernel} \
line 2, \
line 3, ${distro} \
line 4 \
line 5 \
EOL \
如果你想直接从Dockerfile运行它(没有额外的脚本),你也可以echo
它并逃避换行符:
printf "line 1, ${kernel}\n line 2,\n line 3, ${distro}\n line 4\n line 5" >> /etc/myconfig.conf
但要小心:在Windows系统上,你需要一个\r\n