Example: Creating inline files
WithCOPYinstructions, you can replace the source parameter with a here-doc
indicator to write the contents of the here-document directly to a file. The
following example creates agreeting.txtfile containinghello worldusing
aCOPYinstruction.
Regular here-docvariable expansion and tab stripping rulesapply.
The following example shows a small Dockerfile that creates ahello.shscript
file using aCOPYinstruction with a here-document.
In this case, file script prints "hello bar", because the variable is expanded
when theCOPYinstruction gets executed.
If instead you were to quote any part of the here-document wordEOT, the
variable would not be expanded at build-time.
Note thatARG FOO=baris excessive here, and can be removed. The variable
gets interpreted at runtime, when the script is invoked: