How do I run a shell script and jar application in a docker image?

How do I run a shell script(not a oneliner rather say 20-30 lines) and jar application in a docker image at the Entrypoint? Looks like I can specify only one EntryPoint?

  • Docker local repository deletion does not free space
  • Is it possible in some way to use POSIX semaphores between Docker containers or between a container and the host?
  • Run OpenCv in jupyter with Docker
  • Extend docker postgres image to create extra database
  • custom docker image is not running postgres
  • VisualVM unable to connect remote tomcat in docker with RMI
  • Call rabbitmq from nodejs
  • How to re-bind docker volume after removing data-only container?
  • hyperkube gets stuck while trying to start the API server
  • Docker volumes qustion
  • What deletes docker images periodically?
  • Best way to copy files from Docker volume on remote server to local host?
  • One Solution collect form web for “How do I run a shell script and jar application in a docker image?”

    The best approach is to add the folder that contains your shell-script and jar application to the Dockerfile.

    Suppose you have your shellscript and jar application in a folder app along side Dockerfile. Your directory structure would look something like

    $ ls
    Dockerfile
    app
    – shell-script.sh
    – myapplication.jar

    Add the folder app to the Dockerfile

    From ubuntu:15.04 # choose right image here add java and other dependencies
    ADD app /app
    CMD /app/shell-script.sh && java -jar /app/myapplication.jar

    Build the image and run
    $ docker run -it imageName.

    During development, avoid building the docker image everytime you change your script or jar application by mounting the folder at the same place you placed your folder in the Dockerfile and run the container. This will save you a lot of time.

    docker run -it -v $(pwd)/app:/app imageName

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