From edae8cf6a4f69ad91292431afe8c69ee1cac2838 Mon Sep 17 00:00:00 2001 From: Ashton Eby Date: Fri, 13 Dec 2024 15:00:33 -0800 Subject: [PATCH] provide better help text if docker daemon is not running --- src/lib/docker-containers.mjs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/lib/docker-containers.mjs b/src/lib/docker-containers.mjs index a9f2ff98..1154a799 100644 --- a/src/lib/docker-containers.mjs +++ b/src/lib/docker-containers.mjs @@ -28,16 +28,28 @@ export async function ensureContainerRunning({ color: _color, }) { color = _color; - if (pull) { - await pullImage(IMAGE_NAME); + let logStream; + try { + if (pull) { + await pullImage(IMAGE_NAME); + } + logStream = await startContainer({ + imageName: IMAGE_NAME, + containerName, + hostIp, + hostPort, + containerPort, + }); + } catch (error) { + if (error.message.includes("connect ENOENT /var/run/docker.sock")) { + throw new CommandError( + "Could not connect to docker daemon. Please ensure that it is currently running.", + ); + } else { + throw error; + } } - const logStream = await startContainer({ - imageName: IMAGE_NAME, - containerName, - hostIp, - hostPort, - containerPort, - }); + stderr( `[StartContainer] Container '${containerName}' started. Monitoring HealthCheck for readiness.`, );