Docker compose allows you very unrestrictive naming of your environment variables. It allows you to use hyphen and other "special" characters in variables names. When you need to use these variables in regular shell you are out of luck, bash and many other shells do not allow hyphens in variable names. But this is merely a shell restriction, so how to do it?
With env
1 2 3 4 5 6 |
env -i 'TZ=Europe/Berlin' \ 'PORT=8080' \ 'BASE-URL=http://localhost:8080' \ 'DB[0]_CONNECTION-URL=jdbc:postgresql://localhost:5432/postgres' \ 'DB[0]_USERNAME=username' \ 'DB[0]_PASSWORD=password' java -jar myapp.jar |
Note that env ignores all inherited env variables so you might need to redefine them:
1 2 3 |
env -i JAVA_HOME=$JAVA_HOME \ 'TZ=Europe/Berlin' \ 'PORT=8080' java -jar myapp.jar |
3261 Total Views 1 Views Today

GitHub
Eurobattle.net
Lagabuse.com
Bnetdocs