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:

  • Get Docker application link into pm2
  • Where to find the OS that I installed using Docker?
  • Docker-Composer exited with code 0
  • Install docker 1.11 on Fedora 21
  • docker ubuntu cron -f is not working
  • install docker on debian - 'overlay' is not supported over overlayfs
  • $> 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.

  • Sh : file not found on alpine Docker image
  • maven plugin for docker (e.g. to run with needed db)
  • Managing remote docker machines from multiple development machines
  • Docker - Namespaces query [closed]
  • INFO hdfs.HDFSEventSink: Writer callback called
  • tomcat7 fail to start inside Ubuntu Docker container
  • 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.