-
Notifications
You must be signed in to change notification settings - Fork 809
Open
Labels
area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplicationIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Description
See the conversation in dotnet/aspire-samples#1480 (comment)
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:
public static TBuilder WithRandomVolumeNames<TBuilder>(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<ContainerMountAnnotation>()
.Where(m => m.Type == ContainerMountType.Volume && !string.IsNullOrEmpty(m.Source))
.Select(m => (Resource: r, Volume: m)))
.ToList();
var seenVolumes = new HashSet<string>();
var renamedVolumes = new Dictionary<string, string>();
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplicationIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication