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.

  • netcat udp connection hang inside UDP conatiner
  • What is meant by shared kernel in Docker?
  • Nginx load balancer upstream SSL and Docker
  • Gearmand Does Not Start - Socket Address Family Not Supported
  • Can a Dockerfile extend another one?
  • Non-root user in Docker
  • 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.

  • In docker node_modules directory becomes unreachable
  • SSH Agent forwarding inside docker compose container
  • Cannot find module for a node js app running in a docker compose environment
  • Passing interpolated environment variables in Jenkinsfile
  • Run Docker PHP-apache: Forbidden You don't have permission to access / on this server
  • Types of errors docker in Windows?
  • 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.