aspire
aspire copied to clipboard
AddContainer fails cryptically if a fully qualified image name is used
If you're familiar with docker, you may try to do one of the following
var redis= builder.AddContainer("redis", "redis:latest");
var sql = builder.AddContainer("sql", "mcr.microsoft.com/mssql/server:2022-latest");
Both of these will be accepted by the app host builder, but will then fail with a cryptic error later on:
could not create the container {"Container": {"name":"reds"}, "Reconciliation": 3, "error": "CreateContainer command returned error code 1 Stdout: '' Stderr: 'invalid reference format\n'"}
This is because aspire expects the registry, image and tag to be provided separately i.e.
var redis = builder.AddContainer("redis","redis", "latest");
var sql = builder.AddContainer("sql", "mssql/server", "2022-latest").WithImageRegistry("mcr.microsoft.com");
This seems like an easy mistake for users familiar with docker to make. This could be improved by either:
- Fail fast if a fully qualified reference is provided to
AddContainer(string, string)
(i.e. does the string contain:
or.
) - Accept a fully qualified reference in
AddContainer(string, string)