How can I get the output?
See original GitHub issueI can’t find the way to get the output from the container
public static void main(String[] args) throws InterruptedException {
DockerClient docker = DockerClientBuilder
.getInstance("tcp://127.0.0.1:2376")
.build();
// Run
CreateContainerResponse container = docker
.createContainerCmd("ubuntu")
.withCmd("/bin/sh", "-c", "echo Hello world!")
.withTty(true)
.exec();
// Log
LogContainerResultCallback loggingCallback = new
LogContainerResultCallback();
docker
.logContainerCmd(container.getId())
.withStdErr(true)
.withStdOut(true)
.withFollowStream(true)
.withTailAll()
.exec(loggingCallback)
.awaitStarted();
loggingCallback.awaitCompletion(3, TimeUnit.SECONDS);
String output = loggingCallback.toString();
System.out.println(output);
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
How to execute a command and get the output ... - Tutorialspoint
You can use the popen and pclose functions to pipe to and from processes. The popen() function opens a process by creating a...
Read more >How can i get output in my HTML page using Javascript
The id in <input type="text" id="Password" /> has an upper case P, while in javascript you are calling it with a lower case...
Read more >How to see output of C program in Linux or UNIX - nixCraft
Task: Execute program to see output. Above command will create a file called a.out. To see output of test.c program type: $ ./a.out ......
Read more >Basic Input, Output, and String Formatting in Python
In this tutorial, you'll learn about Python input and output. ... Output can be displayed directly to the console or IDE, to the...
Read more >How can I get the output and test the dig command?
The following command will capture the output of the IP address and put it into a shell variable. $ IP=$(dig +short www.google.com |...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This works for me:
@ketansgaikwad05 see the note: https://github.com/docker-java/docker-java/blob/e01dd42d4041870147163dc78323bfc94b51bb57/docker-java-core/src/main/java/com/github/dockerjava/core/command/LogContainerResultCallback.java#L16