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:

  • Connect to Windows 10 Docker daemon from ubuntu bash
  • Wrap application deployables in Docker Image
  • Mesos cannot deploy container from private Docker registry
  • Linking containers in Docker
  • How to use the Docker Build Step Jenkins plugin?
  • Cannot find a valid baseurl for repo: base/7/x86_64 when build docker image
  • $> 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.

  • prepend command with env variable - including sub command
  • Unable to run rabbitmq using marathon mesos
  • eenvsubst not substitituing value for varable
  • Is it desirable to use Ansible for creating a docker image
  • Is it recommended to run docker swarm on single node?
  • Docker Machine can ssh but not scp
  • 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.