Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit b67aeba

Browse files
authored
Merge pull request #105 from docker/skip-copy-config-for-dd
Skip copy config on DD local and cloud
2 parents 6b5c20d + 1ff4a56 commit b67aeba

File tree

8 files changed

+87
-73
lines changed

8 files changed

+87
-73
lines changed

commands/compose.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7+
"github.com/docker/model-cli/pkg/types"
78
"github.com/spf13/pflag"
89
"slices"
910
"strings"
@@ -48,7 +49,7 @@ func newUpCommand() *cobra.Command {
4849
if err != nil {
4950
_ = sendErrorf("Failed to initialize standalone model runner: %v", err)
5051
return fmt.Errorf("Failed to initialize standalone model runner: %w", err)
51-
} else if ((kind == desktop.ModelRunnerEngineKindMoby || kind == desktop.ModelRunnerEngineKindCloud) &&
52+
} else if ((kind == types.ModelRunnerEngineKindMoby || kind == types.ModelRunnerEngineKindCloud) &&
5253
standalone == nil) ||
5354
(standalone != nil && (standalone.gatewayIP == "" || standalone.gatewayPort == 0)) {
5455
return errors.New("unable to determine standalone runner endpoint")
@@ -79,13 +80,13 @@ func newUpCommand() *cobra.Command {
7980
}
8081

8182
switch kind {
82-
case desktop.ModelRunnerEngineKindDesktop:
83+
case types.ModelRunnerEngineKindDesktop:
8384
_ = setenv("URL", "http://model-runner.docker.internal/engines/v1/")
84-
case desktop.ModelRunnerEngineKindMobyManual:
85+
case types.ModelRunnerEngineKindMobyManual:
8586
_ = setenv("URL", modelRunner.URL("/engines/v1/"))
86-
case desktop.ModelRunnerEngineKindCloud:
87+
case types.ModelRunnerEngineKindCloud:
8788
fallthrough
88-
case desktop.ModelRunnerEngineKindMoby:
89+
case types.ModelRunnerEngineKindMoby:
8990
_ = setenv("URL", fmt.Sprintf("http://%s:%d/engines/v1", standalone.gatewayIP, standalone.gatewayPort))
9091
default:
9192
return fmt.Errorf("unhandled engine kind: %v", kind)

commands/install-runner.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"github.com/docker/model-cli/pkg/types"
78
"os"
89
"time"
910

@@ -77,8 +78,8 @@ func inspectStandaloneRunner(container container.Summary) *standaloneRunner {
7778
func ensureStandaloneRunnerAvailable(ctx context.Context, printer standalone.StatusPrinter) (*standaloneRunner, error) {
7879
// If we're not in a supported model runner context, then don't do anything.
7980
engineKind := modelRunner.EngineKind()
80-
standaloneSupported := engineKind == desktop.ModelRunnerEngineKindMoby ||
81-
engineKind == desktop.ModelRunnerEngineKindCloud
81+
standaloneSupported := engineKind == types.ModelRunnerEngineKindMoby ||
82+
engineKind == types.ModelRunnerEngineKindCloud
8283
if !standaloneSupported {
8384
return nil, nil
8485
}
@@ -127,11 +128,11 @@ func ensureStandaloneRunnerAvailable(ctx context.Context, printer standalone.Sta
127128
// Create the model runner container.
128129
port := uint16(standalone.DefaultControllerPortMoby)
129130
environment := "moby"
130-
if engineKind == desktop.ModelRunnerEngineKindCloud {
131+
if engineKind == types.ModelRunnerEngineKindCloud {
131132
port = standalone.DefaultControllerPortCloud
132133
environment = "cloud"
133134
}
134-
if err := standalone.CreateControllerContainer(ctx, dockerClient, port, environment, false, gpu, modelStorageVolume, printer); err != nil {
135+
if err := standalone.CreateControllerContainer(ctx, dockerClient, port, environment, false, gpu, modelStorageVolume, printer, engineKind); err != nil {
135136
return nil, fmt.Errorf("unable to initialize standalone model runner container: %w", err)
136137
}
137138

@@ -166,14 +167,14 @@ func newInstallRunner() *cobra.Command {
166167
RunE: func(cmd *cobra.Command, args []string) error {
167168
// Ensure that we're running in a supported model runner context.
168169
engineKind := modelRunner.EngineKind()
169-
if engineKind == desktop.ModelRunnerEngineKindDesktop {
170+
if engineKind == types.ModelRunnerEngineKindDesktop {
170171
// TODO: We may eventually want to auto-forward this to
171172
// docker desktop enable model-runner, but we should first make
172173
// sure the CLI flags match.
173174
cmd.Println("Standalone installation not supported with Docker Desktop")
174175
cmd.Println("Use `docker desktop enable model-runner` instead")
175176
return nil
176-
} else if engineKind == desktop.ModelRunnerEngineKindMobyManual {
177+
} else if engineKind == types.ModelRunnerEngineKindMobyManual {
177178
cmd.Println("Standalone installation not supported with MODEL_RUNNER_HOST set")
178179
return nil
179180
}
@@ -185,14 +186,14 @@ func newInstallRunner() *cobra.Command {
185186
// when context detection happens. So assume that a default value
186187
// indicates that we want the Cloud default port. This is less
187188
// problematic in Cloud since the UX there is mostly invisible.
188-
if engineKind == desktop.ModelRunnerEngineKindCloud &&
189+
if engineKind == types.ModelRunnerEngineKindCloud &&
189190
port == standalone.DefaultControllerPortMoby {
190191
port = standalone.DefaultControllerPortCloud
191192
}
192193

193194
// Set the appropriate environment.
194195
environment := "moby"
195-
if engineKind == desktop.ModelRunnerEngineKindCloud {
196+
if engineKind == types.ModelRunnerEngineKindCloud {
196197
environment = "cloud"
197198
}
198199

@@ -238,7 +239,7 @@ func newInstallRunner() *cobra.Command {
238239
return fmt.Errorf("unable to initialize standalone model storage: %w", err)
239240
}
240241
// Create the model runner container.
241-
if err := standalone.CreateControllerContainer(cmd.Context(), dockerClient, port, environment, doNotTrack, gpu, modelStorageVolume, cmd); err != nil {
242+
if err := standalone.CreateControllerContainer(cmd.Context(), dockerClient, port, environment, doNotTrack, gpu, modelStorageVolume, cmd, engineKind); err != nil {
242243
return fmt.Errorf("unable to initialize standalone model runner container: %w", err)
243244
}
244245

commands/logs.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"errors"
77
"fmt"
8+
"github.com/docker/model-cli/pkg/types"
89
"io"
910
"os"
1011
"os/signal"
@@ -37,8 +38,8 @@ func newLogsCmd() *cobra.Command {
3738
// If we're running in standalone mode, then print the container
3839
// logs.
3940
engineKind := modelRunner.EngineKind()
40-
useStandaloneLogs := engineKind == desktop.ModelRunnerEngineKindMoby ||
41-
engineKind == desktop.ModelRunnerEngineKindCloud
41+
useStandaloneLogs := engineKind == types.ModelRunnerEngineKindMoby ||
42+
engineKind == types.ModelRunnerEngineKindCloud
4243
if useStandaloneLogs {
4344
dockerClient, err := desktop.DockerClientForContext(dockerCLI, dockerCLI.CurrentContext())
4445
if err != nil {

commands/status.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package commands
33
import (
44
"encoding/json"
55
"fmt"
6+
"github.com/docker/model-cli/pkg/types"
67
"os"
78

89
"github.com/docker/cli/cli-plugins/hooks"
@@ -74,13 +75,13 @@ func jsonStatus(standalone *standaloneRunner, status desktop.Status, backendStat
7475
var endpoint string
7576
kind := modelRunner.EngineKind()
7677
switch kind {
77-
case desktop.ModelRunnerEngineKindDesktop:
78+
case types.ModelRunnerEngineKindDesktop:
7879
endpoint = "http://model-runner.docker.internal/engines/v1/"
79-
case desktop.ModelRunnerEngineKindMobyManual:
80+
case types.ModelRunnerEngineKindMobyManual:
8081
endpoint = modelRunner.URL("/engines/v1/")
81-
case desktop.ModelRunnerEngineKindCloud:
82+
case types.ModelRunnerEngineKindCloud:
8283
fallthrough
83-
case desktop.ModelRunnerEngineKindMoby:
84+
case types.ModelRunnerEngineKindMoby:
8485
endpoint = fmt.Sprintf("http://%s:%d/engines/v1", standalone.gatewayIP, standalone.gatewayPort)
8586
default:
8687
return fmt.Errorf("unhandled engine kind: %v", kind)

commands/uninstall-runner.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package commands
22

33
import (
44
"fmt"
5+
"github.com/docker/model-cli/pkg/types"
56

67
"github.com/docker/model-cli/commands/completion"
78
"github.com/docker/model-cli/desktop"
@@ -16,14 +17,14 @@ func newUninstallRunner() *cobra.Command {
1617
Short: "Uninstall Docker Model Runner",
1718
RunE: func(cmd *cobra.Command, args []string) error {
1819
// Ensure that we're running in a supported model runner context.
19-
if kind := modelRunner.EngineKind(); kind == desktop.ModelRunnerEngineKindDesktop {
20+
if kind := modelRunner.EngineKind(); kind == types.ModelRunnerEngineKindDesktop {
2021
// TODO: We may eventually want to auto-forward this to
2122
// docker desktop disable model-runner, but we should first
2223
// make install-runner forward in the same way.
2324
cmd.Println("Standalone uninstallation not supported with Docker Desktop")
2425
cmd.Println("Use `docker desktop disable model-runner` instead")
2526
return nil
26-
} else if kind == desktop.ModelRunnerEngineKindMobyManual {
27+
} else if kind == types.ModelRunnerEngineKindMobyManual {
2728
cmd.Println("Standalone uninstallation not supported with MODEL_RUNNER_HOST set")
2829
return nil
2930
}

desktop/context.go

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package desktop
33
import (
44
"context"
55
"fmt"
6+
"github.com/docker/model-cli/pkg/types"
67
"net/http"
78
"net/url"
89
"os"
@@ -79,47 +80,11 @@ func DockerClientForContext(cli *command.DockerCli, name string) (*clientpkg.Cli
7980
)
8081
}
8182

82-
// ModelRunnerEngineKind encodes the kind of Docker engine associated with the
83-
// model runner context.
84-
type ModelRunnerEngineKind uint8
85-
86-
const (
87-
// ModelRunnerEngineKindMoby represents a non-Desktop/Cloud engine on which
88-
// the Model CLI command is responsible for managing a Model Runner.
89-
ModelRunnerEngineKindMoby ModelRunnerEngineKind = iota
90-
// ModelRunnerEngineKindMobyManual represents a non-Desktop/Cloud engine
91-
// that's explicitly targeted by a MODEL_RUNNER_HOST environment variable on
92-
// which the user is responsible for managing a Model Runner.
93-
ModelRunnerEngineKindMobyManual
94-
// ModelRunnerEngineKindDesktop represents a Docker Desktop engine. It only
95-
// refers to a Docker Desktop Linux engine, i.e. not a Windows container
96-
// engine in the case of Docker Desktop for Windows.
97-
ModelRunnerEngineKindDesktop
98-
// ModelRunnerEngineKindCloud represents a Docker Cloud engine.
99-
ModelRunnerEngineKindCloud
100-
)
101-
102-
// String returns a human-readable engine kind description.
103-
func (k ModelRunnerEngineKind) String() string {
104-
switch k {
105-
case ModelRunnerEngineKindMoby:
106-
return "Docker Engine"
107-
case ModelRunnerEngineKindMobyManual:
108-
return "Docker Engine (Manual Install)"
109-
case ModelRunnerEngineKindDesktop:
110-
return "Docker Desktop"
111-
case ModelRunnerEngineKindCloud:
112-
return "Docker Cloud"
113-
default:
114-
return "Unknown"
115-
}
116-
}
117-
11883
// ModelRunnerContext encodes the operational context of a Model CLI command and
11984
// provides facilities for inspecting and interacting with the Model Runner.
12085
type ModelRunnerContext struct {
12186
// kind stores the associated engine kind.
122-
kind ModelRunnerEngineKind
87+
kind types.ModelRunnerEngineKind
12388
// urlPrefix is the prefix URL for all requests.
12489
urlPrefix *url.URL
12590
// client is the model runner client.
@@ -134,7 +99,7 @@ func NewContextForMock(client DockerHttpClient) *ModelRunnerContext {
13499
panic("error occurred while parsing known-good URL")
135100
}
136101
return &ModelRunnerContext{
137-
kind: ModelRunnerEngineKindDesktop,
102+
kind: types.ModelRunnerEngineKindDesktop,
138103
urlPrefix: urlPrefix,
139104
client: client,
140105
}
@@ -150,25 +115,25 @@ func DetectContext(ctx context.Context, cli *command.DockerCli) (*ModelRunnerCon
150115
treatDesktopAsMoby := os.Getenv("_MODEL_RUNNER_TREAT_DESKTOP_AS_MOBY") == "1"
151116

152117
// Detect the associated engine type.
153-
kind := ModelRunnerEngineKindMoby
118+
kind := types.ModelRunnerEngineKindMoby
154119
if modelRunnerHost != "" {
155-
kind = ModelRunnerEngineKindMobyManual
120+
kind = types.ModelRunnerEngineKindMobyManual
156121
} else if isDesktopContext(ctx, cli) {
157-
kind = ModelRunnerEngineKindDesktop
122+
kind = types.ModelRunnerEngineKindDesktop
158123
if treatDesktopAsMoby {
159-
kind = ModelRunnerEngineKindMoby
124+
kind = types.ModelRunnerEngineKindMoby
160125
}
161126
} else if isCloudContext(cli) {
162-
kind = ModelRunnerEngineKindCloud
127+
kind = types.ModelRunnerEngineKindCloud
163128
}
164129

165130
// Compute the URL prefix based on the associated engine kind.
166131
var rawURLPrefix string
167-
if kind == ModelRunnerEngineKindMoby {
132+
if kind == types.ModelRunnerEngineKindMoby {
168133
rawURLPrefix = "http://localhost:" + strconv.Itoa(standalone.DefaultControllerPortMoby)
169-
} else if kind == ModelRunnerEngineKindCloud {
134+
} else if kind == types.ModelRunnerEngineKindCloud {
170135
rawURLPrefix = "http://localhost:" + strconv.Itoa(standalone.DefaultControllerPortCloud)
171-
} else if kind == ModelRunnerEngineKindMobyManual {
136+
} else if kind == types.ModelRunnerEngineKindMobyManual {
172137
rawURLPrefix = modelRunnerHost
173138
} else { // ModelRunnerEngineKindDesktop
174139
rawURLPrefix = "http://localhost" + inference.ExperimentalEndpointsPrefix
@@ -180,7 +145,7 @@ func DetectContext(ctx context.Context, cli *command.DockerCli) (*ModelRunnerCon
180145

181146
// Construct the HTTP client.
182147
var client DockerHttpClient
183-
if kind == ModelRunnerEngineKindDesktop {
148+
if kind == types.ModelRunnerEngineKindDesktop {
184149
dockerClient, err := DockerClientForContext(cli, cli.CurrentContext())
185150
if err != nil {
186151
return nil, fmt.Errorf("unable to create model runner client: %w", err)
@@ -199,7 +164,7 @@ func DetectContext(ctx context.Context, cli *command.DockerCli) (*ModelRunnerCon
199164
}
200165

201166
// EngineKind returns the Docker engine kind associated with the model runner.
202-
func (c *ModelRunnerContext) EngineKind() ModelRunnerEngineKind {
167+
func (c *ModelRunnerContext) EngineKind() types.ModelRunnerEngineKind {
203168
return c.kind
204169
}
205170

pkg/standalone/containers.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/docker/docker/client"
2020
"github.com/docker/go-connections/nat"
2121
gpupkg "github.com/docker/model-cli/pkg/gpu"
22+
"github.com/docker/model-cli/pkg/types"
2223
)
2324

2425
// controllerContainerName is the name to use for the controller container.
@@ -31,7 +32,13 @@ var concurrentInstallMatcher = regexp.MustCompile(`is already in use by containe
3132

3233
// copyDockerConfigToContainer copies the Docker config file from the host to the container
3334
// and sets up proper ownership and permissions for the modelrunner user.
34-
func copyDockerConfigToContainer(ctx context.Context, dockerClient *client.Client, containerID string) error {
35+
// It does nothing for Desktop and Cloud engine kinds.
36+
func copyDockerConfigToContainer(ctx context.Context, dockerClient *client.Client, containerID string, engineKind types.ModelRunnerEngineKind) error {
37+
// Do nothing for Desktop and Cloud engine kinds
38+
if engineKind == types.ModelRunnerEngineKindDesktop || engineKind == types.ModelRunnerEngineKindCloud {
39+
return nil
40+
}
41+
3542
dockerConfigPath := os.ExpandEnv("$HOME/.docker/config.json")
3643
if s, err := os.Stat(dockerConfigPath); err != nil || s.Mode()&os.ModeType != 0 {
3744
return nil
@@ -215,7 +222,7 @@ func waitForContainerToStart(ctx context.Context, dockerClient client.ContainerA
215222
}
216223

217224
// CreateControllerContainer creates and starts a controller container.
218-
func CreateControllerContainer(ctx context.Context, dockerClient *client.Client, port uint16, environment string, doNotTrack bool, gpu gpupkg.GPUSupport, modelStorageVolume string, printer StatusPrinter) error {
225+
func CreateControllerContainer(ctx context.Context, dockerClient *client.Client, port uint16, environment string, doNotTrack bool, gpu gpupkg.GPUSupport, modelStorageVolume string, printer StatusPrinter, engineKind types.ModelRunnerEngineKind) error {
219226
// Determine the target image.
220227
var imageName string
221228
switch gpu {
@@ -294,7 +301,7 @@ func CreateControllerContainer(ctx context.Context, dockerClient *client.Client,
294301
}
295302

296303
// Copy Docker config file if it exists
297-
if err := copyDockerConfigToContainer(ctx, dockerClient, resp.ID); err != nil {
304+
if err := copyDockerConfigToContainer(ctx, dockerClient, resp.ID, engineKind); err != nil {
298305
// Log warning but continue - don't fail container creation
299306
printer.Printf("Warning: failed to copy Docker config: %v\n", err)
300307
}

pkg/types/engine.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package types
2+
3+
// ModelRunnerEngineKind encodes the kind of Docker engine associated with the
4+
// model runner context.
5+
type ModelRunnerEngineKind uint8
6+
7+
const (
8+
// ModelRunnerEngineKindMoby represents a non-Desktop/Cloud engine on which
9+
// the Model CLI command is responsible for managing a Model Runner.
10+
ModelRunnerEngineKindMoby ModelRunnerEngineKind = iota
11+
// ModelRunnerEngineKindMobyManual represents a non-Desktop/Cloud engine
12+
// that's explicitly targeted by a MODEL_RUNNER_HOST environment variable on
13+
// which the user is responsible for managing a Model Runner.
14+
ModelRunnerEngineKindMobyManual
15+
// ModelRunnerEngineKindDesktop represents a Docker Desktop engine. It only
16+
// refers to a Docker Desktop Linux engine, i.e. not a Windows container
17+
// engine in the case of Docker Desktop for Windows.
18+
ModelRunnerEngineKindDesktop
19+
// ModelRunnerEngineKindCloud represents a Docker Cloud engine.
20+
ModelRunnerEngineKindCloud
21+
)
22+
23+
// String returns a human-readable engine kind description.
24+
func (k ModelRunnerEngineKind) String() string {
25+
switch k {
26+
case ModelRunnerEngineKindMoby:
27+
return "Docker Engine"
28+
case ModelRunnerEngineKindMobyManual:
29+
return "Docker Engine (Manual Install)"
30+
case ModelRunnerEngineKindDesktop:
31+
return "Docker Desktop"
32+
case ModelRunnerEngineKindCloud:
33+
return "Docker Cloud"
34+
default:
35+
return "Unknown"
36+
}
37+
}

0 commit comments

Comments
 (0)