Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions commands/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ func newUpCommand() *cobra.Command {
_ = setenv("URL", "http://model-runner.docker.internal/engines/v1/")
} else if kind == desktop.ModelRunnerEngineKindMobyManual {
_ = setenv("URL", modelRunner.URL("/engines/v1/"))
} else if kind == desktop.ModelRunnerEngineKindMoby || kind == desktop.ModelRunnerEngineKindCloud {
// TODO: Find a more robust solution in Moby-like environments.
_ = setenv("URL", "http://host.docker.internal:"+strconv.Itoa(standalone.DefaultControllerPort)+"/engines/v1/")
} else if kind == desktop.ModelRunnerEngineKindMoby {
// TODO: Use more robust detection in Moby-like environments.
_ = setenv("URL", "http://host.docker.internal:"+strconv.Itoa(standalone.DefaultControllerPortMoby)+"/engines/v1/")
} else if kind == desktop.ModelRunnerEngineKindCloud {
// TODO: Use more robust detection in Cloud environments.
_ = setenv("URL", "http://host.docker.internal:"+strconv.Itoa(standalone.DefaultControllerPortCloud)+"/engines/v1/")
}
return nil
},
Expand Down
25 changes: 21 additions & 4 deletions commands/install-runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ func ensureStandaloneRunnerAvailable(ctx context.Context, printer standalone.Sta
}

// Create the model runner container.
if err := standalone.CreateControllerContainer(ctx, dockerClient, standalone.DefaultControllerPort, gpu, modelStorageVolume, printer); err != nil {
port := uint16(standalone.DefaultControllerPortMoby)
if engineKind == desktop.ModelRunnerEngineKindCloud {
port = standalone.DefaultControllerPortCloud
}
if err := standalone.CreateControllerContainer(ctx, dockerClient, port, gpu, modelStorageVolume, printer); err != nil {
return fmt.Errorf("unable to initialize standalone model runner container: %w", err)
}

Expand All @@ -112,18 +116,31 @@ func newInstallRunner() *cobra.Command {
Short: "Install Docker Model Runner",
RunE: func(cmd *cobra.Command, args []string) error {
// Ensure that we're running in a supported model runner context.
if kind := modelRunner.EngineKind(); kind == desktop.ModelRunnerEngineKindDesktop {
engineKind := modelRunner.EngineKind()
if engineKind == desktop.ModelRunnerEngineKindDesktop {
// TODO: We may eventually want to auto-forward this to
// docker desktop enable model-runner, but we should first make
// sure the CLI flags match.
cmd.Println("Standalone installation not supported with Docker Desktop")
cmd.Println("Use `docker desktop enable model-runner` instead")
return nil
} else if kind == desktop.ModelRunnerEngineKindMobyManual {
} else if engineKind == desktop.ModelRunnerEngineKindMobyManual {
cmd.Println("Standalone installation not supported with MODEL_RUNNER_HOST set")
return nil
}

// HACK: If we're in a Cloud context, then we need to use a
// different default port because it conflicts with Docker Desktop's
// default model runner host-side port. Unfortunately we can't make
// the port flag default dynamic (at least not easily) because of
// when context detection happens. So assume that a default value
// indicates that we want the Cloud default port. This is less
// problematic in Cloud since the UX there is mostly invisible.
if engineKind == desktop.ModelRunnerEngineKindCloud &&
port == standalone.DefaultControllerPortMoby {
port = standalone.DefaultControllerPortCloud
}

// Create a Docker client for the active context.
dockerClient, err := desktop.DockerClientForContext(dockerCLI, dockerCLI.CurrentContext())
if err != nil {
Expand Down Expand Up @@ -176,7 +193,7 @@ func newInstallRunner() *cobra.Command {
},
ValidArgsFunction: completion.NoComplete,
}
c.Flags().Uint16Var(&port, "port", standalone.DefaultControllerPort,
c.Flags().Uint16Var(&port, "port", standalone.DefaultControllerPortMoby,
"Docker container port for Docker Model Runner")
c.Flags().StringVar(&gpuMode, "gpu", "auto", "Specify GPU support (none|auto|cuda)")
return c
Expand Down
8 changes: 5 additions & 3 deletions desktop/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,16 @@ func DetectContext(cli *command.DockerCli) (*ModelRunnerContext, error) {

// Compute the URL prefix based on the associated engine kind.
var rawURLPrefix string
if kind == ModelRunnerEngineKindMoby || kind == ModelRunnerEngineKindCloud {
rawURLPrefix = "http://localhost:" + strconv.Itoa(int(standalone.DefaultControllerPort))
if kind == ModelRunnerEngineKindMoby {
rawURLPrefix = "http://localhost:" + strconv.Itoa(standalone.DefaultControllerPortMoby)
} else if kind == ModelRunnerEngineKindCloud {
rawURLPrefix = "http://localhost:" + strconv.Itoa(standalone.DefaultControllerPortCloud)
} else if kind == ModelRunnerEngineKindMobyManual {
rawURLPrefix = modelRunnerHost
} else { // ModelRunnerEngineKindDesktop
rawURLPrefix = "http://localhost" + inference.ExperimentalEndpointsPrefix
if treatDesktopAsMoby {
rawURLPrefix = "http://localhost:" + strconv.Itoa(int(standalone.DefaultControllerPort))
rawURLPrefix = "http://localhost:" + strconv.Itoa(standalone.DefaultControllerPortMoby)
}
}
urlPrefix, err := url.Parse(rawURLPrefix)
Expand Down
11 changes: 8 additions & 3 deletions pkg/standalone/ports.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package standalone

// DefaultControllerPort is the default TCP port on which the standalone
// controller will listen for requests.
const DefaultControllerPort = 12434
const (
// DefaultControllerPortMoby is the default TCP port on which the standalone
// controller will listen for requests in Moby environments.
DefaultControllerPortMoby = 12434
// DefaultControllerPortCloud is the default TCP port on which the
// standalone controller will listen for requests in Moby environments.
DefaultControllerPortCloud = 12435
)