* Verify the Docker daemon is installed and reachable before doing any build * or run work, so the user gets one clear message instead of a cryptic exit * code from whichever Docker command happened to run first. `docker info` * connects to the daemon and exits non-zero (125) when it can't.
(out: DevOutput)
| 339 | * connects to the daemon and exits non-zero (125) when it can't. |
| 340 | */ |
| 341 | async function assertDockerAvailable(out: DevOutput): Promise<void> { |
| 342 | try { |
| 343 | await runForwarded( |
| 344 | 'docker', |
| 345 | ['info', '--format', '{{.ServerVersion}}'], |
| 346 | out, |
| 347 | { |
| 348 | quiet: true, |
| 349 | } |
| 350 | ); |
| 351 | } catch (err) { |
| 352 | const message = (err as Error).message ?? ''; |
| 353 | if (/command not found/i.test(message)) { |
| 354 | throw new Error( |
| 355 | 'Docker is required for `vercel dev` with containers, but the ' + |
| 356 | '`docker` command was not found. Install Docker and ensure it is ' + |
| 357 | 'on your PATH.' |
| 358 | ); |
| 359 | } |
| 360 | throw new Error( |
| 361 | 'Could not connect to the Docker daemon. Start Docker (e.g. open ' + |
| 362 | 'Docker Desktop) and run `vercel dev` again.' |
| 363 | ); |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | /** |
| 368 | * Build a helpful error for a `docker run` that exited before the container |
no test coverage detected