How to deploy stack with docker-java client?
ex) docker stack deploy –compose-file docker-compose.yml stackdemo
Is there any function to run this command in java client?
Advertisement
Answer
If you want to execute multiple commands I suggest you to write a shell script file and execute it from the java code.
{ Process proc = Runtime.getRuntime().exec("./your_script.sh"); proc.waitFor(); }
Another option if you want to only run 1 command you can use ProcessBuilder
{ String[] args = new String[] {"/bin/bash", "-c", "your_command", "with", "args"}; Process proc = new ProcessBuilder(args).start(); }