Compose: docker compose file: how to write an environment variable in multiple lines

Created on 30 Oct 2017  路  2Comments  路  Source: docker/compose

I'd like to write my environment variable in multiple lines because it is too long and it would be easier to read when it would be written in multiple lines.
E.g. I have Docker file:
_FROM openjdk
COPY ./container /opt
WORKDIR /opt
CMD java ${JAVA_OPTIONS} -cp "./:lib/" mypackage.AppMain_
I'd like to have an opportunity to write in my compose file something like this:
_version: '3'
services:
myservice:
image: myregistry/myapp
container_name: myservice
environment:
- JAVA_OPTIONS="\
-Dcom.sun.management.jmxremote \
-Djava.rmi.server.hostname=127.0.0.1 \
-Dcom.sun.management.jmxremote.port=7001 \
-Dcom.sun.management.jmxremote.rmi.port=7001 \
-Dcom.sun.management.jmxremote.local.only=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false"
ports:
- 7001:7001_
Is it possible and how to do this?

kinquestion

All 2 comments

Thnk u. Really sorry. This question isn't about docker-compose.
It works. My example of docker-compose.yml:
version: '3'
services:
ubunt_printenv:
image: ubuntu
container_name: ubunt_printenv
command: printenv
environment:
java_arguments: >-
-Dcom.sun.management.jmxremote
-Djava.rmi.server.hostname=127.0.0.1
-Dcom.sun.management.jmxremote.port=8081
-Dcom.sun.management.jmxremote.rmi.port=8081
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
java_class_path: "./
:lib/
"

Was this page helpful?
0 / 5 - 0 ratings