Docker Community Forums

Share and learn in the Docker community.

Run a java application like daemon in docker run?


(Huangyingw) #1

Hi, I want to launch a java image, and run the following command in the background, like a daemon.
java -Dkms.ws.uri=ws://ipaddress:8888/kurento -Dapp.server.url=http://ipaddress:8089/ -Dserver.port=8089 -jar /root/service/lib/company-group-call.jar &>/dev/null &
So, I try to launch the java docker image in following way, but the image only run once and terminated. I have tried both -ti and -d option in run command.
How could I run a java application like daemon in docker run?

========================
#!/bin/bash
SCRIPT_DIR=$(dirname $0)
docker run
-v /Users/huangyingw/myproject/git/work/company/service/:/root/service/
–env-file $SCRIPT_DIR/env.list
-h kurento
-p 8888:8888
-p 8089:8089
-ti java bash -c “java -Dkms.ws.uri=ws://ipaddress:8888/kurento -Dapp.server.url=http://ipaddress:8089/ -Dserver.port=8089 -jar /root/service/lib/company-group-call.jar &>/dev/null &”