In the current version of Docker.DotNet (v3.125.15), there is no support for handling the Systemerr stream when demultiplexing events from Docker.
When docker sends Systemerr, the library throws an IOException with the message "unknown stream type"
Reproduce
To reproduce this issue, we have a valid container f13d4aec
Ensure that docker logs command exited with non-zero code
root@domain:~# docker logs f13d4aec
error from daemon in stream: Error grabbing logs: invalid character 'i' looking for beginning of object key string
root@domain:~# echo $?
1
Using the library to view logs
using Docker.DotNet;
using Docker.DotNet.Models;
var client = new DockerClientConfiguration(
new Uri("http://192.168.1.189:2375"))
.CreateClient();
var response = await client.Containers.GetContainerLogsAsync("f13d4aec", false, new ContainerLogsParameters()
{
ShowStdout = true
});
var (stdout, stderr) = await response.ReadOutputToEndAsync(CancellationToken.None);
This will throw an exception
System.IO.IOException: unknown stream type
Changes
Therefore, this PR introduces a new handler for Systemerr stream within Docerk.DotNet.
It reads the message and throws a DockerDaemonException instead of the generic IOException
The message in the exception was completely copied from moby's behavior to provide clear guidance on troubleshooting known issues
Now the exception will look like this
Docker.DotNet.Daemon.DockerDaemonException: error from daemon in stream: Error grabbing logs: invalid character 'i' looking for beginning of object key string
Context
In the current version of Docker.DotNet (v3.125.15), there is no support for handling the Systemerr stream when demultiplexing events from Docker.
When docker sends
Systemerr
, the library throws anIOException
with the message "unknown stream type"Reproduce
To reproduce this issue, we have a valid container
f13d4aec
Steps
Break json in logs to simulate a scenario where Docker would send a
SystemErr
Ensure that
docker logs
command exited with non-zero codeUsing the library to view logs
This will throw an exception
Changes
Therefore, this PR introduces a new handler for
Systemerr
stream within Docerk.DotNet.It reads the message and throws a
DockerDaemonException
instead of the genericIOException
The message in the exception was completely copied from moby's behavior to provide clear guidance on troubleshooting known issues
Now the exception will look like this