Skip to content

Commit 9b342d2

Browse files
fix: handle DOS-style path for Dockerfile in minikube build
1 parent aca5f29 commit 9b342d2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

cmd/minikube/cmd/image.go

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"k8s.io/minikube/pkg/minikube/exit"
3131
"k8s.io/minikube/pkg/minikube/image"
3232
"k8s.io/minikube/pkg/minikube/machine"
33+
"k8s.io/minikube/pkg/minikube/out"
3334
"k8s.io/minikube/pkg/minikube/reason"
3435
docker "k8s.io/minikube/third_party/go-dockerclient"
3536
)
@@ -310,6 +311,12 @@ var buildImageCmd = &cobra.Command{
310311
// Otherwise, assume it's a tar
311312
}
312313
}
314+
if runtime.GOOS == "windows" && strings.Contains(dockerFile, "\\") {
315+
// if dockerFile is a DOS path, and user did not explicitly forbid this conversion, translate it into UNIX path
316+
// because we are going to build this image in UNIX environment
317+
out.String("minikube detects that you are using DOS-style path %s. minikube will convert it to UNIX-style by replacing all \\ to /", dockerFile)
318+
dockerFile = strings.ReplaceAll(dockerFile, "\\", "/")
319+
}
313320
if err := machine.BuildImage(img, dockerFile, tag, push, buildEnv, buildOpt, []*config.Profile{profile}, allNodes, nodeName); err != nil {
314321
exit.Error(reason.GuestImageBuild, "Failed to build image", err)
315322
}

test/integration/functional_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func validateImageCommands(ctx context.Context, t *testing.T, profile string) {
299299
// docs: Make sure image building works by `minikube image build`
300300
t.Run("ImageBuild", func(t *testing.T) {
301301
MaybeParallel(t)
302-
302+
303303
if _, err := Run(t, exec.CommandContext(ctx, Target(), "-p", profile, "ssh", "pgrep", "buildkitd")); err == nil {
304304
t.Errorf("buildkitd process is running, should not be running until `minikube image build` is ran")
305305
}

0 commit comments

Comments
 (0)