How to pass multiline variable to docker container?

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

environment:
  KEY: |-
    line1
    line2

However, when I execute echo $KEYin the container, it replaced the new line with spaces:

line1 line2

Am I missing something? The version for dockers is 1.12.1.

+4
source share
2 answers

The syntax of YAML is correct. The shell command was not:

echo "$KEY"

prints a line with newline characters.

+4
source

There was the same problem a couple of days ago and solved it through:

KEY: "line1\nline2"

Hope this helps in your case too.

+2
source

Source: https://habr.com/ru/post/1657307/


All Articles