I have an entry point as shown here
ENTRYPOINT /usr/bin/java ... /usr/path/$FILE
I am trying to pass an environment variable while starting container
-e FILE=myfile.txt
However this value does not seem to be replaced. Java throws an exception that /usr/path is a directory . If I hard code the entrypoint with a file name in the dockerfile, it works perfectly fine.
ENTRYPOINT /usr/bin/java ... /usr/path/myfile.txt
It confirms $FILE is not replaced.
How to fix this?
NOTE:
Interestingly docker-compose works perfectly fine!!
environment:
- FILE=myfile.txt
In order to ensure that the shell form of ENTRYPOINT, that you correctly are using, does substitute the environment variable $FILE, add an exec:
ENTRYPOINT exec /usr/bin/java ... "/usr/path/$FILE"
Then check that your docker run -e FILE=xxx yourImage does work.
That supposes that your Dockefile includes an ENV FILE aDefaultFile directive, in order for docker run -e to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With