Skip to content

Instantly share code, notes, and snippets.

@usmansaleem
Created September 4, 2017 23:03
Show Gist options
  • Save usmansaleem/bb47064f406c105fdfa69716544b7b8e to your computer and use it in GitHub Desktop.
Save usmansaleem/bb47064f406c105fdfa69716544b7b8e to your computer and use it in GitHub Desktop.
multiline docker environment variable (via docker compose)
environment:
SERVER_NAME: "myserver.doma.in"
# Dummy key, cert
SSL_KEY: |-
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQD272jYrLm8Ph5QpMWFcWUO9Ua1EviykalP+tkMIg12yZ3GvezF
y8aayxdztB5vu68jqMeg6mOJlscWqFUhmAxj4mDknYenVzVX2CKzCgHlGninTKxY
61rXDaDZVpSZ+XIESJkaB0z9HHYtrSLr0coKmq4cT5TRptOnkpDlJxIRaQIDAQAB
AoGATcTYoGTFmiN2KK+8BWrRCQT2X9C5woNdb3LxKIEQ/HhC2HS4PRMQWW/c0vPH
IilZ30EoneUztAFochpRtWLNg4lJoLy04X/eNjEiC/imp0KSwWXmnuLhDcWcb0+M
slddvzHAAfK1jzIk8zEvcFnhuRoR/L3yWLQp3dIkG07h5IECQQD7xdyhfYMKiYZ7
HIq9mU0oNaC7UvxHTw3HB4rT3yvqVZXW15JvR64qCe+sOn9xJEesGDkUUxghV+dd
0GFOODPb2trQ1NGyKzus72JvO61pVpIhT6kVQo3xC543/+1FvU+albjtmqKe1MjZ
32B6VtNdlgA4VzMC7qrZXwU+oD83WbG6s1GKQa/rXB8wo9moOGcNPP7PmXovDr6F
zIVbekIj0YuTQdo31aKPNmrTVqd+iOk0LGaUC5zMi0OgDaKKDuP1Ou6ANVTcBXcF
BnJRQ7XYtjs0oSmvA7bgbTfN4IMJxJ4hYybF1pURh/o4QW4FUytLaF8zghuTc0aP
yKIsFLzi5ZT34KLVNGAEA44FsG71hOajFkA4c2I/SwU+
-----END RSA PRIVATE KEY-----
@rafa-munoz
Copy link

Thank you, exactly what I was looking for!

@darrena092
Copy link

Thanks!

@VitorDaynno
Copy link

Thanks!

@frankh
Copy link

frankh commented Sep 15, 2020

this doesn't work...

@usmansaleem
Copy link
Author

@frankh

this doesn't work...

This is standard yaml string literal style. The | is for literal. The - is for not using trailing \n. Take a look at:

https://symfony.com/doc/current/components/yaml/yaml_format.html

@frankh
Copy link

frankh commented Sep 16, 2020

let me clarify: docker-compose (as of 1.26.2 at least) drops the newlines no matter how you set the var in yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment