I want to set a multiline environment variable in my Dockerfile.
Works through command line
If I pass in the environment variable through docker run everything works.
CONFIG="port: 4466
databases:
prod:
connector: mysql
active: true
host: 33.333.333.333
port: 3306
user: root
password: pass"
docker run --env CONFIG="$CONFIG" ubuntu:latest env | grep 'CONFIG'
Output (its only a single line because its interpreted as multiline variable)
CONFIG=port: 4466
Doesnt Work through dockerfile
Dockerfile
FROM ubuntu:latest
ENV CONFIG 'port: 4466\ndatabases:\n prod:\n connector: mysql\n active: true\n host: host\n port: 3306\n user: root\n password: pass'
Build and run the docker image
docker build -t multilinetest .
docker run multilinetest env | grep 'CONFIG'
Output
CONFIG=port: 4466\ndatabases:\n prod:\n connector: mysql\n active: true\n host: host\n port: 3306\n user: root\n password: pass
Expected
Both scenarios should store the same environment variable (I'm passing this environment variable into a 3rd party image that requires a multiline string)