@@ -96,7 +96,11 @@ func ensureStandaloneRunnerAvailable(ctx context.Context, printer standalone.Sta
9696 }
9797
9898 // Create the model runner container.
99- if err := standalone .CreateControllerContainer (ctx , dockerClient , standalone .DefaultControllerPort , gpu , modelStorageVolume , printer ); err != nil {
99+ port := uint16 (standalone .DefaultControllerPortMoby )
100+ if engineKind == desktop .ModelRunnerEngineKindCloud {
101+ port = standalone .DefaultControllerPortCloud
102+ }
103+ if err := standalone .CreateControllerContainer (ctx , dockerClient , port , gpu , modelStorageVolume , printer ); err != nil {
100104 return fmt .Errorf ("unable to initialize standalone model runner container: %w" , err )
101105 }
102106
@@ -112,18 +116,31 @@ func newInstallRunner() *cobra.Command {
112116 Short : "Install Docker Model Runner" ,
113117 RunE : func (cmd * cobra.Command , args []string ) error {
114118 // Ensure that we're running in a supported model runner context.
115- if kind := modelRunner .EngineKind (); kind == desktop .ModelRunnerEngineKindDesktop {
119+ engineKind := modelRunner .EngineKind ()
120+ if engineKind == desktop .ModelRunnerEngineKindDesktop {
116121 // TODO: We may eventually want to auto-forward this to
117122 // docker desktop enable model-runner, but we should first make
118123 // sure the CLI flags match.
119124 cmd .Println ("Standalone installation not supported with Docker Desktop" )
120125 cmd .Println ("Use `docker desktop enable model-runner` instead" )
121126 return nil
122- } else if kind == desktop .ModelRunnerEngineKindMobyManual {
127+ } else if engineKind == desktop .ModelRunnerEngineKindMobyManual {
123128 cmd .Println ("Standalone installation not supported with MODEL_RUNNER_HOST set" )
124129 return nil
125130 }
126131
132+ // HACK: If we're in a Cloud context, then we need to use a
133+ // different default port because it conflicts with Docker Desktop's
134+ // default model runner host-side port. Unfortunately we can't make
135+ // the port flag default dynamic (at least not easily) because of
136+ // when context detection happens. So assume that a default value
137+ // indicates that we want the Cloud default port. This is less
138+ // problematic in Cloud since the UX there is mostly invisible.
139+ if engineKind == desktop .ModelRunnerEngineKindCloud &&
140+ port == standalone .DefaultControllerPortMoby {
141+ port = standalone .DefaultControllerPortCloud
142+ }
143+
127144 // Create a Docker client for the active context.
128145 dockerClient , err := desktop .DockerClientForContext (dockerCLI , dockerCLI .CurrentContext ())
129146 if err != nil {
@@ -176,7 +193,7 @@ func newInstallRunner() *cobra.Command {
176193 },
177194 ValidArgsFunction : completion .NoComplete ,
178195 }
179- c .Flags ().Uint16Var (& port , "port" , standalone .DefaultControllerPort ,
196+ c .Flags ().Uint16Var (& port , "port" , standalone .DefaultControllerPortMoby ,
180197 "Docker container port for Docker Model Runner" )
181198 c .Flags ().StringVar (& gpuMode , "gpu" , "auto" , "Specify GPU support (none|auto|cuda)" )
182199 return c
0 commit comments