If you don’t mind not using the .env
file (maybe that environment variable is used only in a single container). You can define environment variables directly inside docker-compose.yml
and there, you can make full use of YAML formatting options. I.e.:
myservice:
build: .
environment:
SSH_KEY: >
--------- WHATEVER ----------
randomkeybase64thingforyourse
rvice
------- END WHATEVER --------
And as a side note, you don’t have to copy .env
values inside the environment
section. .env
variables are used inside the docker-compose.yml
file, but not in the container’s environment. However, you can do:
myservice:
build: .
env_file:
# Files in this array have the same format as `.env` files, but they are
# passed to container's environment instead being used inside this
# `docker-compose.yml` file
- variables.env
environment:
SSH_KEY: >
--------- WHATEVER ----------
randomkeybase64thingforyourse
rvice
------- END WHATEVER --------