@@ -19,10 +19,10 @@ import {
1919 buildApiBaseUrlCandidates ,
2020 type DockerNetworkIps ,
2121 formatNetworkIps ,
22- isRemoteDockerHost ,
2322 resolveApiPort ,
2423 resolveConfiguredApiBaseUrl ,
2524 resolveExplicitApiBaseUrl ,
25+ shouldRequireExplicitApiUrlForRemoteDocker ,
2626 trimTrailingSlashes
2727} from "./controller-reachability.js"
2828import {
@@ -98,9 +98,17 @@ const waitForReachableApiBaseUrl = (
9898 } )
9999 )
100100
101- const failIfRemoteDockerWithoutApiUrl = ( ) : Effect . Effect < void , ControllerBootstrapError > => {
101+ const failIfRemoteDockerWithoutApiUrl = (
102+ currentContainerNetworks : DockerNetworkIps
103+ ) : Effect . Effect < void , ControllerBootstrapError > => {
102104 const explicitApiBaseUrl = resolveExplicitApiBaseUrl ( )
103- if ( ! isRemoteDockerHost ( ) || explicitApiBaseUrl !== undefined ) {
105+ if (
106+ ! shouldRequireExplicitApiUrlForRemoteDocker (
107+ process . env [ "DOCKER_HOST" ] ,
108+ explicitApiBaseUrl ,
109+ currentContainerNetworks
110+ )
111+ ) {
104112 return Effect . void
105113 }
106114
@@ -266,7 +274,6 @@ const startAndRememberController = (
266274// COMPLEXITY: O(1) compose + O(k) health checks
267275export const ensureControllerReady = ( ) : Effect . Effect < void , ControllerBootstrapError , ControllerRuntime > =>
268276 Effect . gen ( function * ( _ ) {
269- yield * _ ( failIfRemoteDockerWithoutApiUrl ( ) )
270277 const explicitApiBaseUrl = resolveExplicitApiBaseUrl ( )
271278 const localControllerRevision = yield * _ ( prepareLocalControllerRevision ( ) )
272279 const forceRecreateForResourceLimits = shouldForceRecreateForControllerResourceLimits ( )
@@ -300,6 +307,7 @@ export const ensureControllerReady = (): Effect.Effect<void, ControllerBootstrap
300307 }
301308
302309 const bootstrapContext = yield * _ ( loadControllerBootstrapContext ( ) )
310+ yield * _ ( failIfRemoteDockerWithoutApiUrl ( bootstrapContext . currentContainerNetworks ) )
303311 const reusedExistingController = yield * _ ( reuseReachableControllerIfPossible ( bootstrapContext ) )
304312 if ( reusedExistingController ) {
305313 return
@@ -309,14 +317,14 @@ export const ensureControllerReady = (): Effect.Effect<void, ControllerBootstrap
309317
310318export const restartController = ( ) : Effect . Effect < void , ControllerBootstrapError , ControllerRuntime > =>
311319 Effect . gen ( function * ( _ ) {
312- yield * _ ( failIfRemoteDockerWithoutApiUrl ( ) )
313320 const explicitApiBaseUrl = resolveExplicitApiBaseUrl ( )
314321 if ( explicitApiBaseUrl !== undefined ) {
315322 yield * _ ( ensureControllerReady ( ) )
316323 return
317324 }
318325
319326 const bootstrapContext = yield * _ ( loadControllerBootstrapContext ( ) )
327+ yield * _ ( failIfRemoteDockerWithoutApiUrl ( bootstrapContext . currentContainerNetworks ) )
320328 const forceRecreateController = true
321329 const buildController = shouldBuildControllerImage ( {
322330 currentControllerRevision : bootstrapContext . currentControllerRevision ,
0 commit comments