giraff giraff - 1 month ago 24
YAML Question

How can I pass a multi-line variable to a docker container?

According to this comment, multi-line variables are supported with

docker compose
:

environment:
KEY: |-
line1
line2


However, when I execute
echo $KEY
in the container, it has replaced the newline with spaces:

line1 line2


Am I missing something? My docker version is 1.12.1.

Answer

The YAML syntax is correct. The shell command wasn't:

echo "$KEY"

prints the string with newlines.

Comments