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?
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/"
Most helpful comment
https://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines