I am a beginner in using Docker. I'm using Docker toolbox for Windows 7 , i built an image for my python web app and everything works fine.
However, for this app, i use nltk module which also needs java and java_home setting to the java file. When running on my computer, i can mannualy set the java_home, but how to do it in the dockerfile so that it wont get error when running on another machine. Here is my error :
p.s : Answer below
When you are running a container you have the option of passing in environment variables that will be set in your container using the
-e
flag. This answer explains environment variables nicely: How do I pass environment variables to Docker containers?docker container run -e JAVA_HOME='/path/to/java' <your image>
Make sure your image actually contains Java as well. You might want to look at something like the
openjdk:8
image on docker hub.It sounds like you need a docker file to build your image. Have a look at the
ENV
command documented here to set theJAVA_HOME
var: https://docs.docker.com/engine/reference/builder/#env and then build your image withdocker build /path/to/Dockerfile
I see you've already tried that and didn't have much luck.. run the container and instead of running your application process just run a bash script along the lines of
echo $JAVA_HOME
so you can at least verify that part is working.Also make sure you copy in whatever files/binaries needed to the appropriate directories within the image in the docker file as noted below.