Docker.DotNet
Docker.DotNet copied to clipboard
How to force Docker.DotNet (NET CORE) read last log records
I try to use this package with my project, but failed. Unfortunately many function working in my project with troubles. This is my code to read docker container logs.
Function ReadContainerLog(DockerHub As DockerClient, ContainerID As String, Readlog As Action(Of String), LogsCts As CancellationToken) As Task
Dim ContainerLogsTask As Task = DockerHub.Containers.GetContainerLogsAsync(
ContainerID,
New ContainerLogsParameters With {
.ShowStderr = True,
.ShowStdout = True,
.Timestamps = True,
.Follow = True
},
LogsCts,
New Progress(Of String)(Readlog)
)
Return ContainerLogsTask
End Function
Module Program
Sub Main(args As String())
Dim LogCtsSrc As New CancellationTokenSource()
Dim ContainerLogs As New List(Of String)
Public Sub ReadLog(Line As String)
If LogCtsSrc.IsCancellationRequested Then Exit Sub
ContainerLogs.Add(Line)
End Sub
...
ReadContainerLog(DockerHub, ContainerId, AddressOf ReadLog, LogCtsSrc.Token)
'
Console.ReadKey()
Task.Delay(TimeSpan.FromSeconds(5))
LogCtsSrc.Cancel()
'
Dim j As Integer = 0
ContainerLogs.ForEach(Sub(X)
j = j + 1
Console.WriteLine(j.ToString & ": " & X)
End Sub)
Unfortunately, last records don't read from docker socket and don't pass to my software. Please see to screenshot.

What I doing wrong and how to force pass last log records from buffer to my software?