[英]How to run a Docker image from a Java program?
That's what I would do in the command line: 这就是我在命令行中要做的事情:
$ docker run -i imagename mycommand
Should I just use Runtime.getRuntime().exe()
? 我应该只使用
Runtime.getRuntime().exe()
吗? Should I use one of the available Java APIs ? 我应该使用其中一个可用的Java API吗?
From what I've seen, the APIs would help me to pull and push images, but all I want is to run a particular command on a particular public image, and I don't seem to find an easy way to do that with the APIs. 从我所看到的,API将帮助我拉动和推送图像,但我想要的只是在特定的公共图像上运行特定的命令,我似乎没有找到一个简单的方法来做到这一点蜜蜂。
I'm attaching the actual command I'd be executing, just in case: 我附加了我正在执行的实际命令,以防万一:
$ docker run --rm -p 8080:8080 -i owasp/zap2docker-stable zap.sh -daemon -port 8080
You should think to use java api to manage docker images/container. 您应该考虑使用java api来管理docker images / container。
You can start with any of them 你可以从任何一个开始
Java docker-java https://github.com/docker-java/docker-java Active
Java docker-client https://github.com/spotify/docker-client Active
Refer: 参考:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.