Score:0

How to run docker commands in java 19

cg flag

I am trying to run docker commands in java, to create a Dockerfile and create a container out of it. It can be done in another way, but this is what I tried so far:

ProcessBuilder processBuilder = new ProcessBuilder(new String[]{"cd", "/home/alex/IdeaProjects/test/src/Docker", "&& docker", "build", " -f", "Dockerfile.txt", "-t", "java-app1", "."});
            processBuilder.inheritIO();
            processBuilder.directory(new File("bin"));
            processBuilder.start();

        

This an other way:

Runtime.getRuntime().exec(new String[]{"cd", "/home/alex/IdeaProjects/test/src/Docker", "&& docker", "build", " -f", "Dockerfile.txt", "-t", "java-app1", "."});

Is is possible to create custom containers directly from java?

David avatar
cn flag
What version of Ubuntu are you using? That question seems better suited to a Docker or Java forum.
ilie alexandru avatar
cg flag
Hello David, I am using ubuntu 22.04
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.