@@ -96,7 +96,11 @@ func ensureStandaloneRunnerAvailable(ctx context.Context, printer standalone.Sta
96
96
}
97
97
98
98
// 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 {
100
104
return fmt .Errorf ("unable to initialize standalone model runner container: %w" , err )
101
105
}
102
106
@@ -112,18 +116,31 @@ func newInstallRunner() *cobra.Command {
112
116
Short : "Install Docker Model Runner" ,
113
117
RunE : func (cmd * cobra.Command , args []string ) error {
114
118
// 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 {
116
121
// TODO: We may eventually want to auto-forward this to
117
122
// docker desktop enable model-runner, but we should first make
118
123
// sure the CLI flags match.
119
124
cmd .Println ("Standalone installation not supported with Docker Desktop" )
120
125
cmd .Println ("Use `docker desktop enable model-runner` instead" )
121
126
return nil
122
- } else if kind == desktop .ModelRunnerEngineKindMobyManual {
127
+ } else if engineKind == desktop .ModelRunnerEngineKindMobyManual {
123
128
cmd .Println ("Standalone installation not supported with MODEL_RUNNER_HOST set" )
124
129
return nil
125
130
}
126
131
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
+
127
144
// Create a Docker client for the active context.
128
145
dockerClient , err := desktop .DockerClientForContext (dockerCLI , dockerCLI .CurrentContext ())
129
146
if err != nil {
@@ -176,7 +193,7 @@ func newInstallRunner() *cobra.Command {
176
193
},
177
194
ValidArgsFunction : completion .NoComplete ,
178
195
}
179
- c .Flags ().Uint16Var (& port , "port" , standalone .DefaultControllerPort ,
196
+ c .Flags ().Uint16Var (& port , "port" , standalone .DefaultControllerPortMoby ,
180
197
"Docker container port for Docker Model Runner" )
181
198
c .Flags ().StringVar (& gpuMode , "gpu" , "auto" , "Specify GPU support (none|auto|cuda)" )
182
199
return c
0 commit comments