@@ -28,17 +28,24 @@ import (
2828// controllerContainerName is the name to use for the controller container.
2929const controllerContainerName = "docker-model-runner"
3030
31- // copyDockerConfigToContainer copies the Docker config file from the host to the container
32- // and sets up proper ownership and permissions for the modelrunner user.
33- // It does nothing for Desktop and Cloud engine kinds.
34- func copyDockerConfigToContainer (ctx context.Context , dockerClient * client.Client , containerID string , engineKind types.ModelRunnerEngineKind ) error {
31+ // SyncDockerConfigToContainer copies the host's ~/.docker/config.json into the
32+ // running container. It is a no-op for Desktop and Cloud engine kinds.
33+ func SyncDockerConfigToContainer (ctx context.Context , dockerClient * client.Client , containerID string , engineKind types.ModelRunnerEngineKind ) error {
3534 // Do nothing for Desktop and Cloud engine kinds
3635 if engineKind == types .ModelRunnerEngineKindDesktop || engineKind == types .ModelRunnerEngineKindCloud ||
3736 os .Getenv ("_MODEL_RUNNER_TREAT_DESKTOP_AS_MOBY" ) == "1" {
3837 return nil
3938 }
4039
41- dockerConfigPath := os .ExpandEnv ("$HOME/.docker/config.json" )
40+ dockerConfigDir := os .Getenv ("DOCKER_CONFIG" )
41+ if dockerConfigDir == "" {
42+ homeDir , err := os .UserHomeDir ()
43+ if err != nil {
44+ return fmt .Errorf ("failed to get home directory: %w" , err )
45+ }
46+ dockerConfigDir = filepath .Join (homeDir , ".docker" )
47+ }
48+ dockerConfigPath := filepath .Join (dockerConfigDir , "config.json" )
4249 if s , err := os .Stat (dockerConfigPath ); err != nil || s .Mode ()& os .ModeType != 0 {
4350 return nil
4451 }
@@ -622,7 +629,7 @@ func CreateControllerContainer(ctx context.Context, dockerClient *client.Client,
622629
623630 // Copy Docker config file if it exists and we're the container creator.
624631 if created && ! vllmOnWSL {
625- if err := copyDockerConfigToContainer (ctx , dockerClient , resp .ID , engineKind ); err != nil {
632+ if err := SyncDockerConfigToContainer (ctx , dockerClient , resp .ID , engineKind ); err != nil {
626633 // Log warning but continue - don't fail container creation
627634 printer .Printf ("Warning: failed to copy Docker config: %v\n " , err )
628635 }
0 commit comments