microsoft/aspire · error · InvalidOperationException

Container runtime did not return image configuration for

Error message

Container runtime did not return image configuration for '{imageReference}'.

What it means

Even when config inspection reports success, the integration requires an actual config payload (TryGetConfig). If the runtime returned a success status but no parseable configuration object, this InvalidOperationException is thrown, indicating an empty or malformed inspection result rather than a hard failure.

Solutions

  1. Verify the runtime can dump the config: `docker image inspect --format '{{json .Config}}' <image>`; if empty, re-pull the image.
  2. Upgrade or align the container runtime version with the Aspire integration expectations.
  3. Re-pull the image (docker pull) to replace a potentially corrupt or anomalous config blob.
  4. If it persists, capture the raw inspect output and file an issue against the integration's runtime adapter.

Example fix

// before (shell)
# runtime returns success but empty config
docker image inspect myapp   # malformed output

// after
docker pull myapp && docker image inspect --format '{{json .Config}}' myapp   # valid config, retry deploy
Defensive patterns

Strategy: retry

Validate before calling

var cfg = await GetImageConfigJsonAsync("docker", "image inspect --format '{{json .Config}}' <image>");
if (string.IsNullOrWhiteSpace(cfg)) throw new InvalidOperationException("Runtime returned empty image config; re-pull the image.");

Try / catch

try
{
    await DeployToSandboxAsync(...);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("did not return image configuration"))
{
    logger.LogWarning(ex, "Empty config from runtime; re-pulling image and retrying.");
    await RepullAndRetryAsync(...);
}

Prevention

When it happens

Trigger: InspectImageConfigAsync returns a non-failed status but the result contains no config entry — e.g. a runtime adapter that reports success with an empty payload, or an image with an anomalous/empty config blob.

Common situations: Bugs or version drift in the container runtime CLI producing output the adapter cannot parse into a config; images with empty/legacy config blobs; adapter/runtime version mismatch after a runtime upgrade.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/1d94f2f94c8cf352. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs:1123

    private static async Task<ContainerImageMetadata> InspectLocalContainerImageAsync(PipelineStepContext context, string imageReference)
    {
        var runtime = await ResolveContainerRuntimeAsync(context).ConfigureAwait(false);
        var result = await runtime.InspectImageConfigAsync(imageReference, context.CancellationToken).ConfigureAwait(false);
        if (result.Status == ContainerImageInspectionStatus.Unsupported)
        {
            throw new NotSupportedException(
                $"Container runtime '{runtime.Name}' does not support image configuration inspection, which is required for Azure sandbox deployment.");
        }

        if (result.Status == ContainerImageInspectionStatus.Failed)
        {
            throw new InvalidOperationException(
                result.ErrorMessage ?? $"Container runtime failed to inspect image configuration '{imageReference}'.");
        }

        if (!result.TryGetConfig(out var config))
        {
            throw new InvalidOperationException($"Container runtime did not return image configuration for '{imageReference}'.");
        }

        return new ContainerImageMetadata(
            config.Entrypoint,
            config.Command,
            new Dictionary<string, string>(StringComparer.Ordinal),
            config.WorkingDirectory,
            new HashSet<string>(StringComparer.OrdinalIgnoreCase));
    }

    private static Task<IContainerRuntime> ResolveContainerRuntimeAsync(PipelineStepContext context)
    {
        return context.Services.GetRequiredService<IContainerRuntimeResolver>().ResolveAsync(context.CancellationToken);
    }

    internal static async Task<ResolvedEnvironmentVariables> ResolveEnvironmentVariablesAsync(PipelineStepContext context, IResource resource)
    {
        var environmentVariables = new Dictionary<string, object>();

View on GitHub (pinned to 25830f84bd)