How to force Docker.DotNet (NET CORE) read last log records
- Dominant language
- C#
- Stars
- 2.4k
- Forks
- 416
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.