{"record":{"id":"259e506be3f92c49","repo":"TryGhost/Ghost","slug":"ghost-container-stopped-during-initialization","errorCode":null,"errorMessage":"Ghost container stopped during initialization","messagePattern":"Ghost container stopped during initialization","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"e2e/helpers/environment/service-managers/ghost-manager.ts","lineNumber":510,"sourceCode":"            const info = await container.inspect();\n            const health = info.State.Health;\n            const status = health?.Status;\n\n            if (info.State.Running && await this.probeHostReadiness()) {\n                debug('Host readiness probe passed');\n                return;\n            }\n\n            if (status === 'unhealthy') {\n                const logs = await container.logs({stdout: true, stderr: true, tail: 100});\n                logging.error(`Container became unhealthy:\\n${logs.toString()}`);\n                throw new Error('Ghost container became unhealthy during initialization');\n            }\n\n            if (!info.State.Running) {\n                const logs = await container.logs({stdout: true, stderr: true, tail: 100});\n                logging.error(`Container stopped unexpectedly:\\n${logs.toString()}`);\n                throw new Error('Ghost container stopped during initialization');\n            }\n\n            // Still starting - wait and check again\n            await new Promise((r) => {\n                setTimeout(r, READINESS_POLL_INTERVAL_MS);\n            });\n        }\n\n        // Timeout\n        const logs = await container.logs({stdout: true, stderr: true, tail: 100});\n        logging.error(`Timeout waiting for container. Last logs:\\n${logs.toString()}`);\n        throw new Error('Timeout waiting for Ghost to become ready');\n    }\n\n    private async probeHostReadiness(): Promise<boolean> {\n        const controller = new AbortController();\n        const timeout = setTimeout(() => controller.abort(), 500);\n","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/TryGhost/Ghost/blob/47d8b0e2ad2fd4757d3bc45f46c3ac165ff8a1fe/e2e/helpers/environment/service-managers/ghost-manager.ts#L492-L528","documentation":"The container exited (info.State.Running is false) during the readiness window — it didn't go unhealthy, it stopped outright. Ghost process crashed or was OOM-killed. The manager dumps 100 log lines at error and aborts. Distinct from 105: unhealthy = running but failing probe; stopped = process gone.","triggerScenarios":"Ghost process threw an unrecoverable error and exited. Container hit a memory limit (OOMKilled). A start dependency (DB) vanished so Ghost exited. The entrypoint script ran exit on a failed preflight.","commonSituations":"Insufficient memory on the Docker host (OOMKilled); missing required env var causing immediate exit; DB connection refused at boot and Ghost gives up; image entrypoint bug after a rebuild.","solutions":["Inspect the dumped logs for the exit cause; also docker inspect <id> and check State.OOMKilled and State.ExitCode.","If OOMKilled, raise Docker memory limits / use a smaller config.","Confirm dependencies (MySQL, gateway) are up before Ghost starts; check startup ordering in the manager.","Rebuild the image if a code change introduced a crash on boot."],"exampleFix":"// diagnostic\nconst info = await container.inspect();\nconsole.log({oom: info.State.OOMKilled, exitCode: info.State.ExitCode});\n// Raise memory or fix the boot crash indicated by the logs.","handlingStrategy":"try-catch","validationCode":"const info = await container.inspect();\nif (!info.State.Running) {\n    throw new Error(`Pre-flight: container not running (OOMKilled=${info.State.OOMKilled}, exit=${info.State.ExitCode})`);\n}","typeGuard":null,"tryCatchPattern":"try {\n    await ghostManager.waitForReady();\n} catch (e) {\n    if (!container) throw e;\n    const info = await container.inspect();\n    if (!info.State.Running) {\n        throw new Error(`Ghost exited during init (OOMKilled=${info.State.OOMKilled}, exitCode=${info.State.ExitCode})`, {cause: e});\n    }\n    throw e;\n}","preventionTips":["Check State.OOMKilled and State.ExitCode via docker inspect on any stop.","Size the Docker host memory to Ghost's needs; raise limits if OOM occurs.","Ensure DB and dependencies are up before Ghost starts."],"tags":["e2e","docker","crash","oom","ghost-startup"],"backgroundTag":null,"analyzedSha":"47d8b0e2ad2fd4757d3bc45f46c3ac165ff8a1fe","analyzedAt":"2026-08-13T01:25:26.651Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}