How to run Docker container from Java project?

Youssef El Rhailani picture Youssef El Rhailani · Jan 10, 2016 · Viewed 10.3k times · Source

How to run a docker container from java code? I'm trying to make a SaaS using docker, once the user logs in, I should start a memcached container from java code, this solution doesn't work:

Process p = Runtime.getRuntime().exec("docker images");

Docker cmds run usually on git bash, not on cmd.
PS: I'm using docker on windows.

Answer

rakesh kotian picture rakesh kotian · Nov 28, 2019

You can do it using https://github.com/docker-java/docker-java . It allows you to build a custom image and run it from java