Null Ports property on ListContainersAsync

Open
#709 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp, docker
Domain
api

Research direction

Start at Containers.ListContainersAsync and the container model's Ports property, using the supplied call with All=true to reproduce a response where Ports is null. Done means containers without ports expose an empty IList rather than null, with regression coverage for that response.

Written by the indexing model from the issue text.

Description

Hi, I found that some containers returned by ListContainersAsync may have a null Ports property instead of returning an empty IList.

Code Example
// DockerClient injected via DI
var dockerContainers = await _dockerClient.Containers.ListContainersAsync(
    new ContainersListParameters { All = true }, cancellationToken);

foreach(var dockerContainer in dockerContainers)
{
    // Ports property may be null
    var ports = dockerContainer.Ports;
}
Inspected Example
Image

In this example you can see the informations related to a container that actuallly has null Ports property.

System Info

Result of dotnet --info:

.NET SDK:
 Version:           10.0.201
 Commit:            4d3023de60
 Workload version:  10.0.200-manifests.121cc9e6
 MSBuild version:   18.3.0-release-26153-122+4d3023de6

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.26200
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\10.0.201\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
  Version:      10.0.5
  Architecture: x64
  Commit:       a612c2a105

.NET SDKs installed:
  10.0.201 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 10.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 10.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 10.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  DOTNET_CLI_UI_LANGUAGE                   [en-US]
  DOTNET_GCHeapCount                       [2]
  DOTNET_GCNoAffinitize                    [1]
  DOTNET_MULTILEVEL_LOOKUP                 [0]
  DOTNET_TC_CallCountThreshold             [1000]
  DOTNET_ThreadPool_UnfairSemaphoreSpinLimit [0]
  DOTNET_gcConcurrent                      [0]
  Detected COMPlus_* environment variable(s). Consider transitioning to DOTNET_* equivalent.

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Docker.DotNet Version:
3.125.15

Dominant language
C#
Stars
2.4k
Forks
416
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/Docker.DotNet

All issues in dotnet/Docker.DotNet

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.