@@ -23,7 +23,7 @@ import { ensureDockerInjectionVolumeExists } from './docker-data-injection';
2323
2424let dockerAvailableCache : Promise < boolean > | undefined ;
2525
26- export const isDockerAvailable = ( ) => {
26+ export const isDockerAvailable = ( options : { logError ?: boolean } = { } ) => {
2727 if ( dockerAvailableCache ) return dockerAvailableCache ;
2828 else {
2929 dockerAvailableCache = ( async ( ) => { // Catch sync & async setup errors
@@ -33,13 +33,15 @@ export const isDockerAvailable = () => {
3333 if ( info . OSType === 'windows' ) {
3434 // We don't support Windows containers yet (and I think they're very rarely
3535 // used anyway) so we treat Windows-mode Docker as unavailable:
36- console . warn ( "Docker is running in Windows container mode - not supported" ) ;
37- return false ;
36+ throw new Error ( "Docker running in Windows container mode - not supported" ) ;
3837 } else {
3938 return true ;
4039 }
4140 } )
42- . catch ( ( ) => false ) ;
41+ . catch ( ( error ) => {
42+ if ( options . logError ) console . warn ( 'Docker not available:' , error . message ) ;
43+ return false ;
44+ } ) ;
4345
4446 // Cache the resulting status for 3 seconds:
4547 setTimeout ( ( ) => { dockerAvailableCache = undefined ; } , 3000 ) ;
@@ -74,11 +76,9 @@ export async function startDockerInterceptionServices(
7476 }
7577
7678 // Log if Docker was not available at proxy start, and why, for debugging later:
77- ( async ( ) => { // Catch sync & async setup errors
78- await new Docker ( ) . ping ( ) ;
79- console . log ( 'Connected to Docker' ) ;
80- } ) ( ) . catch ( ( error ) => {
81- console . warn ( `Docker not available: ${ error . message } ` ) ;
79+ isDockerAvailable ( { logError : true } ) . then ( ( isAvailable ) => {
80+ if ( isAvailable ) console . log ( 'Connected to Docker' ) ;
81+ // logError will log the specific not-available error, if this failed
8282 } ) ;
8383
8484 const networkMonitor = monitorDockerNetworkAliases ( proxyPort ) ;
0 commit comments