Launching Docker demon from Java Service

Trying to launch a docker container in demon mode using shell script from java service deployed on Tomcat, on an ubunty based VM.

I have a java based REST service which has been deployed on tomcat, on the same VM i have installed Docker. I have created a shell file to launch my docker container. When execute this shell file from terminal it works perfectly fine. Although when i execute this shell file from java somehow it doesnt give any error and doesnt execute the docker command inside the shell file.

  • docker secrets for configuration files
  • Testing connection to docker daemon
  • Windows container can't ping Ubuntu container in Swarm
  • Pulling from a local docker image instead
  • Connection error for MongoDb replica-set using docker-compose
  • what is “COPY . /src”for when building a image
  • Note sure if I have missed a point, or have done something wrong. Would be greate if someone can help me.

    Shell File Code snippet.(for testing currently have given Executed permission to all users using chmod 777)

    echo First Parameter is $1
    echo Second Parameter is $2
    echo Third Parameter is $3
    sudo docker run -d -e PARAM1=$1 -e PARAM2=$2 -e PARAM3=$3 --name=$1 <docker_iamge_name>

    Java Codesnippet for calling the script file (note this is not a standalone java class I am using this code snippet inside on Java based REST service which is deployed on Tomcat)

    String command[];
    command = new String[] {"/home/launcher/","Param1","Param2", "Param3"};
    Process process = Runtime.getRuntime().exec(command);

    On Executing the above javascript in the Tomcat sdtout logs get the following

    First Parameter is Param1
    Second Parameter is Param2
    Third Parameter is Param3

    Post which if I check the docker ps -a, I dont see the container getting launched.

    Thanks for Response.

  • Docker-machine host env on multiple computers?
  • Is there any way to obtain detailed logging info when executing 'docker stack deploy'?
  • How to wait till POST request is finished in GO?
  • Composition of services is it possible with kubernetes?
  • Running YARN cluster in Kubernetes/Mesos
  • Why can't the Docker (“master”) container see workers?
  • One Solution collect form web for “Launching Docker demon from Java Service”

    I think your problem is that you are trying to use sudo in your

    To understand what really has happened with a spawned process, you need to read both process.getInputStream() and process.getErrorStream(). The last one will show you exact error (if there was any).

    In your case you should get something like:

    sudo: no tty present and no askpass program specified

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