I hava Java project and I want to execute docker command from my code. Command:
docker run --rm -v "$(pwd)":/browsertime sitespeedio/browsertime:16.3.0 --video --visualMetrics https://www.sitespeed.io/
I have tried to write Java class with following code inside main
-method:
Runtime.getRuntime().exec("docker run --rm -v \"$(pwd)\":/browsertime sitespeedio/browsertime:16.3.0 --video --visualMetrics https://www.sitespeed.io/");
This has compiled fine and got the result in console "Process finished with exit code 0", so everything has been okey, but no result had been got (that command had to create folders and files and so on...).
So how should I run that docker command? If you have answer using DockerClient
(not directly using Runtime.getRuntime().exec
) - then go here: How can I execute predefined docker command from Java application with DockerClient?