简体   繁体   中英

Run <docker> command in Docker container

Now I have a spring boot application that is packaged as jar file. In my application, I have some operations that use Runtime.getRuntime().exec("docker xxx") to interact with the docker in the local shell.

If I want to change the package method that switches the jar file to docker image and run it as a docker container, I think Runtime.getRuntime().exec("docker xxx") would become useless. Therefore, how to change my code? Use docker-java ? or any method for the docker container to interact with the outside docker?

You could use Docker socket binding, ie you could bind-mount /var/run/docker.sock into your container running the Spring Boot app. You'd also have to install Docker CLI into it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM