dotnet / dotnet/Docker.DotNet

How to get service logs using the service id?

Open
#449 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
2.4k
Forks
416
PR merge metrics
No merged PRs in 30d

Description

According to the Docker Engine API (https://docs.docker.com/engine/api/v1.40/#operation/ServiceLogs) I should be able to get the service logs but I can't see anything in Docker.Dotnet to allow me to do it. I have written some code that will create a service (see below) which returns the service id but nothing in the client to allow me to bring back the service logs using it. We have `_client.Containers.GetContainerLogsAsync`, but do we have the equivalent of `_client.Services.GetServiceLogsAsync`?
```
var serviceCreateResponse = await _client
.Swarm
.CreateServiceAsync(new ServiceCreateParameters
{
Service = new ServiceSpec
{
Name = Guid.NewGuid().ToString().Replace("-", string.Empty),
TaskTemplate = new TaskSpec
{
ContainerSpec = new ContainerSpec
{
Image = DukaanDatabaseImage,
Env = new List
{
"POSTGRES_PASSWORD_FILE=/run/secrets/db_postgres_user_password",
"POSTGRES_INITDB_ARGS=--data-checksums"
}
}
},
EndpointSpec = new EndpointSpec
{
Ports = new List
{
new PortConfig
{
PublishedPort = port,
TargetPort = 5432
}
}
}
}
})

var serviceId = serviceCreateResponse.ID
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.