あるフリーランスエンジニアの色んなメモ!! ITスキル・ライフハックとか

Dockerfile内でファイルへ複数行書き込む処理をさせる

実装例

Dockerfile内でこれと同じことをやりたい

cat <<EOF > /path/to/file
foo
bar
baz
EOF

Dockerfile内では echo を使う

RUN echo "foo\n\
bar\n\
baz" >> /path/to/file

参考

launch a CAT command unix into Dockerfile
https://stackoverflow.com/questions/40359282/launch-a-cat-command-unix-into-dockerfile

Multiline Dockerfile syntax
https://github.com/moby/moby/issues/1799#issuecomment-124476047

comments powered by Disqus