Package org.mandas.docker.client
Interface LogStream
- All Superinterfaces:
AutoCloseable,Closeable,Iterator<LogMessage>
-
Method Summary
Modifier and TypeMethodDescriptionvoidattach(OutputStream stdout, OutputStream stderr) Attaches twoOutputStreams to theLogStream.Methods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next, remove
-
Method Details
-
readFully
String readFully() -
attach
Attaches twoOutputStreams to theLogStream.Example usage:
dockerClient .attachContainer(containerId, AttachParameter.LOGS, AttachParameter.STDOUT, AttachParameter.STDERR, AttachParameter.STREAM) .attach(System.out, System.err);Typically you use
PipedOutputStreamconnected to aPipedInputStreamwhich are read by - for example - anInputStreamReaderor aScanner. For small inputs, thePipedOutputStreamjust writes to the buffer of thePipedInputStream, but you actually want to read and write from separate threads, as it may deadlock the thread.final PipedInputStream stdout = new PipedInputStream(); final PipedInputStream stderr = new PipedInputStream(); final PipedOutputStream stdout_pipe = new PipedOutputStream(stdout); final PipedOutputStream stderr_pipe = new PipedOutputStream(stderr); executor.submit(new Callable<Void>() { @Override public Void call() throws Exception { dockerClient.attachContainer(containerId, AttachParameter.LOGS, AttachParameter.STDOUT, AttachParameter.STDERR, AttachParameter.STREAM .attach(stdout_pipe, stderr_pipe); return null; } }); try (Scanner sc_stdout = new Scanner(stdout); Scanner sc_stderr = new Scanner(stderr)) { // ... read here }- Parameters:
stdout- OutputStream for the standard outstderr- OutputStream for the standard err- Throws:
IOException- if an I/O error occurs- See Also:
-