I assume you are using Docker Toolbox for Windows.
The docker command does not take a capital D
. Maybe try with
Process p = Runtime.getRuntime().exec("docker images");
but as you are probably running this code on Windows, that might work anyway.
Another thing to consider is the value of the DOCKER_HOST
environment variable which must be set accordingly to instruct the docker client how to communicate with the docker engine.
In your case the docker client is run on Windows while the docker engine runs inside a virtual machine living in VirtualBox.
The shell provided by Runtime.getRuntime().exec()
won't have the DOCKER_HOST
environment variable set.
Another way is to use the --host
or -H
docker client option to specify how to connect to your docker engine:
Process p = Runtime.getRuntime().exec("docker --host=tcp://<some IP>:2376 images");
Runtime.getRuntime().exec()
is for cmd. @Sokul – Honeycutt