Bash script behaves differently from Docker run command instead of inside container itself?
I am running the Docker 1.0.1 client on Ubuntu 12.0.4 LTS. I have a container that runs a Java application in server mode. There is a Bash script in the container that launches the server. If I execute the bash script from inside the container’s the Java application runs fine. If I append the bash script to the end of the Docker run command and try to launch it that way, the run fails. Checking the logs I see an error indicating the main class for the Java app could not be found.
Here’s the command line:
$> sudo docker run -p 1566:1566 -d $USER/server /server_install/run-server.sh
If I remove /server_install/run-server.sh from the command line, the container launches fine and stays resident. But with the script file in the command line the container terminates and the logs show the error message that indicates the main Java class could not be found. However, if I enter the container and launch run-server.sh from within the /server_install directory, it works fine.
Do paths behave differently from inside a container’s Bash shell then they do when you launch something from the command line? Or do I have to change the current working directory to /server_install before executing the Bash script. If so how do I do that? That seems a little weird because the run-server.sh script sets up the Java path options inside of it.
One Solution collect form web for “Bash script behaves differently from Docker run command instead of inside container itself?”
Or do I have to change the current working directory to /server_install before executing the Bash script. If so how do I do that?
Use the WORKDIR directive in your
My guess is whatever script sets your CLASSPATH takes the current working directory into consideration.