microsoft / microsoft/aspire

aspire-samples tests are failing on latest docker update

Open
#14,603 6 comments 0 reactions 0 assignees View on GitHub
area-app-model
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

See the conversation in https://github.com/dotnet/aspire-samples/pull/1480#issuecomment-3937671887

With the latest Docker version, the aspire-samples tests are failing with errors like:

```
[2026-02-21 00:02:24Z] info: DatabaseContainers.AppHost.Resources.mysql[0]
1: 2026-02-21T00:02:24.1720000Z invalid argument "type=volume,src=,target=/var/lib/mysql" for "--mount" flag: invalid value for 'src': value is empty
[2026-02-21 00:02:24Z] info: DatabaseContainers.AppHost.Resources.sqlserver[0]
1: 2026-02-21T00:02:24.1720000Z invalid argument "type=volume,src=,target=/var/opt/mssql" for "--mount" flag: invalid value for 'src': value is empty
[2026-02-21 00:02:24Z] info: DatabaseContainers.AppHost.Resources.postgres[0]
1: 2026-02-21T00:02:24.1720000Z invalid argument "type=volume,src=,target=/var/lib/postgresql/data" for "--mount" flag: invalid value for 'src': value is empty
```

In the tests, we are changing the volume names with the following code:

```csharp
public static TBuilder WithRandomVolumeNames(this TBuilder builder)
where TBuilder : IDistributedApplicationTestingBuilder
{
// Named volumes that aren't shared across resources should be replaced with anonymous volumes.
// Named volumes shared by mulitple resources need to have their name randomized but kept shared across those resources.

// Find all shared volumes and make a map of their original name to a new randomized name
var allResourceNamedVolumes = builder.Resources.SelectMany(r => r.Annotations
.OfType()
.Where(m => m.Type == ContainerMountType.Volume && !string.IsNullOrEmpty(m.Source))
.Select(m => (Resource: r, Volume: m)))
.ToList();
var seenVolumes = new HashSet();
var renamedVolumes = new Dictionary();
foreach (var resourceVolume in allResourceNamedVolumes)
{
var name = resourceVolume.Volume.Source!;
if (!seenVolumes.Add(name) && !renamedVolumes.ContainsKey(name))
{
renamedVolumes[name] = $"{name}-{Convert.ToHexString(RandomNumberGenerator.GetBytes(4))}";
}
}

// Replace all named volumes with randomly named or anonymous volumes
foreach (var resourceVolume in allResourceNamedVolumes)
{
var resource = resourceVolume.Resource;
var volume = resourceVolume.Volume;
var newName = renamedVolumes.TryGetValue(volume.Source!, out var randomName) ? randomName : null;
var newMount = new ContainerMountAnnotation(newName, volume.Target, ContainerMountType.Volume, volume.IsReadOnly);
resource.Annotations.Remove(volume);
resource.Annotations.Add(newMount);
}

return builder;
}
```

The `var newName = renamedVolumes.TryGetValue(volume.Source!, out var randomName) ? randomName : null;` is the key. We are passing `null` for a `ContainerMountAnnotation` src, which used to work but doesn't with the latest Docker update.

@DamianEdwards @karolz-ms @danegsta

Contributor guide

Open the contributing guide

Research direction

Start by locating WithRandomVolumeNames in the aspire-samples test code and run the failing tests against the latest Docker version. Check the generated ContainerMountAnnotation values and verify that the database container tests pass without empty volume sources while shared volumes remain shared.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, docker
Domain
devops, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.