File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ import {Docker} from '../../src/docker/docker';
2020
2121const maybe = ! process . env . GITHUB_ACTIONS || ( process . env . GITHUB_ACTIONS === 'true' && process . env . ImageOS && process . env . ImageOS . startsWith ( 'ubuntu' ) ) ? describe : describe . skip ;
2222
23+ maybe ( 'isDaemonRunning' , ( ) => {
24+ it ( 'checks if daemon is running' , async ( ) => {
25+ expect ( await Docker . isDaemonRunning ( ) ) . toBe ( true ) ;
26+ } ) ;
27+ } ) ;
28+
2329maybe ( 'pull' , ( ) => {
2430 // prettier-ignore
2531 test . each ( [
Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ export class History {
5050 if ( ! ( await Docker . isAvailable ( ) ) ) {
5151 throw new Error ( 'Docker is required to export a build record' ) ;
5252 }
53+ if ( ! ( await Docker . isDaemonRunning ( ) ) ) {
54+ throw new Error ( 'Docker daemon is not running, skipping build record export' ) ;
55+ }
5356 if ( ! ( await this . buildx . versionSatisfies ( '>=0.13.0' ) ) ) {
5457 throw new Error ( 'Buildx >= 0.13.0 is required to export a build record' ) ;
5558 }
Original file line number Diff line number Diff line change @@ -54,6 +54,17 @@ export class Docker {
5454 } ) ;
5555 }
5656
57+ public static async isDaemonRunning ( ) : Promise < boolean > {
58+ try {
59+ await Docker . getExecOutput ( [ `version` ] , {
60+ silent : true
61+ } ) ;
62+ return true ;
63+ } catch ( e ) {
64+ return false ;
65+ }
66+ }
67+
5768 public static async exec ( args ?: string [ ] , options ?: ExecOptions ) : Promise < number > {
5869 return Exec . exec ( 'docker' , args , Docker . execOptions ( options ) ) ;
5970 }
You can’t perform that action at this time.
0 commit comments