I'm trying to run a command in a docker container using Java's ProcessBuilder. However, it hangs when waiting for exit code. Why is that?
ProcessBuilder processBuilder = new ProcessBuilder(Arrays.asList("/usr/bin/docker", "run", "base", "echo", "hello"));
Process process = processBuilder.start();
// ... Spin off another thread to collect stdout and stderr
int exitCode = process.waitFor(); // <-- HANG
I can see that the process spits out the correct results to stdout. It just never returns an exit code.
echo hellocommand without docker, and it works./usr/bin/docker run base echo hellofrom the command line? Does it exit?