title: Run a docker container from inside java program
body: <p>I try to run a docker container from inside a java program, but the docker container won't run.</p>
  
  <p>When I execute this command I use for the process builder in the terminal the container starts and everything works.</p>
  
  <p>I printed the working directory inside the java program and this is the right directory to start the docker container.</p>
  
  <p>I also changed the command to:</p>
  
  <pre><code>String[] dockerCommand = new String[] {"java", "-cp", "target/MavenAsteroidsServer-1.0-SNAPSHOT.jar", "asteroidsserver.AsteroidsServer", "1600", "1600", "127.0.1.1", "8851", "8901"};
  </code></pre>
  
  <p>This worked, so running the program without a docker container works.</p>
  
  <p>This is the code I used to run the docker container from inside the java program:</p>
  
  <pre><code>String[] dockerCommand = new String[] {"docker", "run", "-it", "--rm", "--net=\"host\"", "-p", "8901:8901", "-v", "\"$PWD\":/app", "-w", "/app", "demo/maven:3.3-jdk-8", "java", "-cp", "target/MavenAsteroidsServer-1.0-SNAPSHOT.jar", "asteroidsserver.AsteroidsServer", "1600", "1600", "127.0.1.1", "8851", "8901"};
  
  ProcessBuilder probuilder = new ProcessBuilder(dockerCommand);
  
  Process process;
  try {
      process = probuilder.start();
      int status = process.waitFor();
  } catch (InterruptedException e) {
  } catch (IOException ex) {
  }
  </code></pre>
  
  <p>I want the container to run, but nothing happens. Also, I get no error messages when I try to catch them in the try and catch block (not shown in the code)</p>