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:

  • How to send application logs from docker to cloudwatch
  • Issue with docker Inter container communication on the isolated bridge
  • Mac: how to remotely access server running inside docker container from other computers?
  • Persistence of Docker Data Containers
  • Kubernetes installation on centos7
  • Run a script when docker is stopped
  • $> 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.

  • How do i enable docker logs for gocd-server?
  • How to create a docker image for a sqlserver2012
  • Understanding docker plugins
  • Connecting to mongo docker container from host
  • cannot build docker image
  • Using docker-compose to start web and backend. How can I get the IP of backend from web?
  • 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 Dockerfile.

    My guess is whatever script sets your CLASSPATH takes the current working directory into consideration.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.