{"record":{"id":"91232199a6bdeaa3","repo":"microsoft/aspire","slug":"container-runtime-containerruntime-name-is-not-running-or-is","errorCode":null,"errorMessage":"Container runtime '{containerRuntime.Name}' is not running or is unhealthy.","messagePattern":"Container runtime '(.+?)' is not running or is unhealthy\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs","lineNumber":225,"sourceCode":"        return options;\n    }\n\n    public async Task BuildImagesAsync(IEnumerable<IResource> resources, CancellationToken cancellationToken = default)\n    {\n        var containerRuntime = await GetContainerRuntimeAsync(cancellationToken).ConfigureAwait(false);\n        logger.LogInformation(\"Starting to build container images\");\n\n        // Only check container runtime health if there are resources that need it\n        if (await ResourcesRequireContainerRuntimeAsync(resources, cancellationToken).ConfigureAwait(false))\n        {\n            logger.LogDebug(\"Checking {ContainerRuntimeName} health\", containerRuntime.Name);\n\n            var containerRuntimeHealthy = await containerRuntime.CheckIfRunningAsync(cancellationToken).ConfigureAwait(false);\n\n            if (!containerRuntimeHealthy)\n            {\n                logger.LogError(\"Container runtime '{ContainerRuntimeName}' is not running or is unhealthy. Cannot build container images.\", containerRuntime.Name);\n                throw new InvalidOperationException($\"Container runtime '{containerRuntime.Name}' is not running or is unhealthy.\");\n            }\n\n            logger.LogDebug(\"{ContainerRuntimeName} is healthy\", containerRuntime.Name);\n        }\n\n        foreach (var resource in resources)\n        {\n            // TODO: Consider parallelizing this.\n            await BuildImageAsync(resource, cancellationToken).ConfigureAwait(false);\n        }\n\n        logger.LogDebug(\"Building container images completed\");\n    }\n\n    public async Task BuildImageAsync(IResource resource, CancellationToken cancellationToken = default)\n    {\n        var containerRuntime = await GetContainerRuntimeAsync(cancellationToken).ConfigureAwait(false);\n        logger.LogInformation(\"Building container image for resource {ResourceName}\", resource.Name);","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs#L207-L243","documentation":"Aspire's ResourceContainerImageManager builds container images for resources during publish. Before building, it verifies the configured container runtime (Docker/Podman) is reachable via CheckIfRunningAsync. If the runtime is not running or unhealthy it throws InvalidOperationException because image builds cannot proceed without a container engine.","triggerScenarios":"Calling BuildImagesAsync (e.g. during 'aspire publish' or publisher pipelines) when no Docker/Podman daemon is running, the daemon socket is unreachable, the container runtime binary is missing, or the daemon is in a paused/unresponsive state.","commonSituations":"Docker Desktop not started after reboot; Podman machine not initialized; running publish inside CI without a container engine; DOCKER_HOST pointing at a dead remote daemon; Docker daemon crashed mid-session.","solutions":["Start your container runtime (launch Docker Desktop, or 'podman machine start' for Podman).","Verify the daemon responds: 'docker info' or 'podman info'.","If using a custom runtime, check its configuration and DOCKER_HOST environment variable.","Re-run the publish/build command once the runtime reports healthy."],"exampleFix":"// before (daemon stopped)\naspire publish\n// error: Container runtime 'docker' is not running or is unhealthy.\n\n// after\nsudo systemctl start docker   # or: open Docker Desktop / podman machine start\naspire publish","handlingStrategy":"try-catch","validationCode":"var healthy = await dockerClient.CheckIfRunningAsync(ct);\nif (!healthy) throw new InvalidOperationException(\"Start Docker/Podman before publishing.\");","typeGuard":null,"tryCatchPattern":"try { await manager.BuildImagesAsync(...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"not running or is unhealthy\"))\n{\n    logger.LogWarning(ex, \"Container runtime unavailable; start Docker/Podman and retry.\");\n}","preventionTips":["Start Docker Desktop / podman machine before running aspire publish.","Add a preflight 'docker info' check in CI before image builds.","Watch for Docker Desktop auto-update/pause states after reboots.","Verify DOCKER_HOST points at a live daemon."],"tags":["docker","container-runtime","publish"],"backgroundTag":"connection-refused","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}