Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Docker container from Java project?

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.

like image 532
Youssef El Rhailani Avatar asked Jan 10 '16 14:01

Youssef El Rhailani


People also ask

Does Docker need Java running?

If you prefer to not install Java on your machine, you can skip this step, and continue straight to the next section, in which we explain how to build and run the application in Docker, which does not require you to have Java installed on your machine. Let's start our application and make sure it is running properly.


1 Answers

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

like image 168
rakesh kotian Avatar answered Sep 19 '22 00:09

rakesh kotian