From e94fd430c2f1e4757e3c2e2acb0bf529ca7f6990 Mon Sep 17 00:00:00 2001 From: vinchenzo-db Date: Sat, 21 Nov 2026 04:11:10 +0000 Subject: [PATCH 1/6] air: warn when a pushed image sets WORKDIR AI Runtime does not honor the Docker WORKDIR directive, so commands that rely on relative paths fail at runtime with file-not-found errors, and nothing warned at push time. `air images push` now inspects the source image's Config.WorkingDir and prints a warning telling the user to use absolute paths. The push itself is unchanged. Co-authored-by: Isaac --- cmd/air/image.go | 20 ++++++++++++++++++++ cmd/air/image_test.go | 44 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/cmd/air/image.go b/cmd/air/image.go index 68bd8d0e9ca..f7f7ce3f7ef 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -205,6 +205,9 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps if got := strings.TrimSpace(platform.String()); got != airImagePlatform { return fmt.Errorf("source image %s has platform %q; AIR requires %s: use --pull to fetch a compatible image, or rebuild the source for %s", resolved.source, got, airImagePlatform, airImagePlatform) } + if err := warnImageWorkingDir(ctx, deps.runCommand, dockerPath, resolved.source, cmd.ErrOrStderr()); err != nil { + return err + } cmdio.LogProgress(ctx, "Tagging image as "+target) if err := deps.runCommand(ctx, cmd.InOrStdin(), cmd.ErrOrStderr(), cmd.ErrOrStderr(), dockerPath, "tag", resolved.source, target); err != nil { @@ -368,6 +371,23 @@ func imageExistsLocally( return strings.TrimSpace(output.String()) != "", nil } +// warnImageWorkingDir warns when the source image sets WORKDIR, which AIR ignores at runtime. +func warnImageWorkingDir( + ctx context.Context, + runCommand func(context.Context, io.Reader, io.Writer, io.Writer, string, ...string) error, + dockerPath, source string, + errOut io.Writer, +) error { + var workingDir bytes.Buffer + if err := runCommand(ctx, nil, &workingDir, errOut, dockerPath, "image", "inspect", "--format", "{{.Config.WorkingDir}}", source); err != nil { + return fmt.Errorf("inspect source image %s: %w", source, err) + } + if dir := strings.TrimSpace(workingDir.String()); dir != "" { + cmdio.LogString(ctx, fmt.Sprintf("Warning: source image %s sets WORKDIR %s, which AI Runtime does not honor at runtime: use absolute paths in your command and scripts.", source, dir)) + } + return nil +} + // runImageCommand runs a subprocess with the supplied context and I/O streams. func runImageCommand(ctx context.Context, in io.Reader, out, errOut io.Writer, executable string, args ...string) error { cmd := exec.CommandContext(ctx, executable, args...) diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index 12e72c1f0cc..c9a6459e294 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -56,6 +56,9 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { _, err := io.WriteString(out, "image-id\n") return err case "image inspect": + if args[3] == "{{.Config.WorkingDir}}" { + return nil + } _, err := io.WriteString(out, "linux/amd64\n") return err } @@ -75,6 +78,7 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { assert.Equal(t, []recordedImageCommand{ {executable: "/usr/bin/docker", args: []string{"image", "ls", "--quiet", "nvidia/cuda:13.4.1"}}, {executable: "/usr/bin/docker", args: []string{"image", "inspect", "--format", "{{.Os}}/{{.Architecture}}", "nvidia/cuda:13.4.1"}}, + {executable: "/usr/bin/docker", args: []string{"image", "inspect", "--format", "{{.Config.WorkingDir}}", "nvidia/cuda:13.4.1"}}, {executable: "/usr/bin/docker", args: []string{"tag", "nvidia/cuda:13.4.1", target}}, {executable: "/usr/bin/docker", args: []string{"push", target}}, }, commands) @@ -85,6 +89,42 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { stderrLines := strings.Split(stderr.String(), "\n") assert.Equal(t, "Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features.", stderrLines[0]) assert.Contains(t, stderr.String(), "Pushed image") + assert.NotContains(t, stderr.String(), "WORKDIR") +} + +func TestRunImagePushWarnsWhenImageSetsWorkingDir(t *testing.T) { + cmd, _, stderr := newImagePushTestCommand(t, "workspace") + deps := imagePushDeps{ + configureDocker: func(context.Context, string) (string, error) { + return "123.container.us-west-2.cloud.databricks.test", nil + }, + lookPath: func(string) (string, error) { return "docker", nil }, + runCommand: func(_ context.Context, _ io.Reader, out, _ io.Writer, _ string, args ...string) error { + switch { + case args[0] == "image" && args[1] == "ls": + _, err := io.WriteString(out, "image-id\n") + return err + case args[0] == "image" && args[1] == "inspect" && args[3] == "{{.Config.WorkingDir}}": + _, err := io.WriteString(out, "/app\n") + return err + case args[0] == "image" && args[1] == "inspect": + _, err := io.WriteString(out, "linux/amd64\n") + return err + } + return nil + }, + } + + err := runImagePush(cmd, &imagePushOptions{ + source: "example/trainer:v1", + catalog: "main", + schema: "training", + artifact: "trainer", + }, deps) + require.NoError(t, err) + + assert.Contains(t, stderr.String(), "Warning: source image example/trainer:v1 sets WORKDIR /app, which AI Runtime does not honor at runtime: use absolute paths in your command and scripts.") + assert.Contains(t, stderr.String(), "Pushed image") } func TestRegistryHostFromDockerConfigureOutput(t *testing.T) { @@ -110,7 +150,7 @@ func TestRunImagePushPullsMissingImage(t *testing.T) { lookPath: func(string) (string, error) { return "docker", nil }, runCommand: func(_ context.Context, _ io.Reader, out, _ io.Writer, executable string, args ...string) error { commands = append(commands, recordedImageCommand{executable: executable, args: args}) - if args[0] == "image" && args[1] == "inspect" { + if args[0] == "image" && args[1] == "inspect" && args[3] != "{{.Config.WorkingDir}}" { _, err := io.WriteString(out, "linux/amd64\n") return err } @@ -126,7 +166,7 @@ func TestRunImagePushPullsMissingImage(t *testing.T) { }, deps) require.NoError(t, err) - require.Len(t, commands, 5) + require.Len(t, commands, 6) assert.Equal(t, []string{"pull", "--platform", "linux/amd64", "example/image:v1"}, commands[1].args) } From 3031cd954d4950b7a2d27417a347b2650b48b798 Mon Sep 17 00:00:00 2001 From: vinchenzo-db Date: Sat, 21 Nov 2026 04:11:26 +0000 Subject: [PATCH 2/6] air: add changelog fragment for WORKDIR warning Co-authored-by: Isaac --- .nextchanges/air/images-push-workdir-warning.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nextchanges/air/images-push-workdir-warning.md diff --git a/.nextchanges/air/images-push-workdir-warning.md b/.nextchanges/air/images-push-workdir-warning.md new file mode 100644 index 00000000000..c4bdfa267ba --- /dev/null +++ b/.nextchanges/air/images-push-workdir-warning.md @@ -0,0 +1 @@ +* Warn in `databricks air images push` when the source image sets `WORKDIR`, which AI Runtime does not honor at runtime, so commands should use absolute paths. ([#7867](https://github.com/databricks/cli/pull/7867)) From 42e16c3d0b7817d37744cda397a3ff92541b6570 Mon Sep 17 00:00:00 2001 From: vinchenzo-db Date: Sat, 21 Nov 2026 04:21:17 +0000 Subject: [PATCH 3/6] air: never block the push on the WORKDIR check An inspect failure now logs a warning instead of aborting, and WORKDIR / (the Docker default) no longer triggers the warning. Co-authored-by: Isaac --- cmd/air/image.go | 14 +++++++------- cmd/air/image_test.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/cmd/air/image.go b/cmd/air/image.go index f7f7ce3f7ef..1e6be54392a 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -205,9 +205,7 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps if got := strings.TrimSpace(platform.String()); got != airImagePlatform { return fmt.Errorf("source image %s has platform %q; AIR requires %s: use --pull to fetch a compatible image, or rebuild the source for %s", resolved.source, got, airImagePlatform, airImagePlatform) } - if err := warnImageWorkingDir(ctx, deps.runCommand, dockerPath, resolved.source, cmd.ErrOrStderr()); err != nil { - return err - } + warnImageWorkingDir(ctx, deps.runCommand, dockerPath, resolved.source, cmd.ErrOrStderr()) cmdio.LogProgress(ctx, "Tagging image as "+target) if err := deps.runCommand(ctx, cmd.InOrStdin(), cmd.ErrOrStderr(), cmd.ErrOrStderr(), dockerPath, "tag", resolved.source, target); err != nil { @@ -372,20 +370,22 @@ func imageExistsLocally( } // warnImageWorkingDir warns when the source image sets WORKDIR, which AIR ignores at runtime. +// The check is advisory, so an inspect failure is reported but never blocks the push. func warnImageWorkingDir( ctx context.Context, runCommand func(context.Context, io.Reader, io.Writer, io.Writer, string, ...string) error, dockerPath, source string, errOut io.Writer, -) error { +) { var workingDir bytes.Buffer if err := runCommand(ctx, nil, &workingDir, errOut, dockerPath, "image", "inspect", "--format", "{{.Config.WorkingDir}}", source); err != nil { - return fmt.Errorf("inspect source image %s: %w", source, err) + cmdio.LogString(ctx, fmt.Sprintf("Warning: couldn't read WORKDIR of source image %s: %v", source, err)) + return } - if dir := strings.TrimSpace(workingDir.String()); dir != "" { + // WORKDIR / is Docker's default and cannot break relative paths. + if dir := strings.TrimSpace(workingDir.String()); dir != "" && dir != "/" { cmdio.LogString(ctx, fmt.Sprintf("Warning: source image %s sets WORKDIR %s, which AI Runtime does not honor at runtime: use absolute paths in your command and scripts.", source, dir)) } - return nil } // runImageCommand runs a subprocess with the supplied context and I/O streams. diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index c9a6459e294..8ad6203a2a3 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -127,6 +127,37 @@ func TestRunImagePushWarnsWhenImageSetsWorkingDir(t *testing.T) { assert.Contains(t, stderr.String(), "Pushed image") } +func TestWarnImageWorkingDir(t *testing.T) { + tests := []struct { + name string + workingDir string + err error + want string + }{ + {name: "unset", workingDir: "\n", want: ""}, + {name: "root", workingDir: "/\n", want: ""}, + {name: "set", workingDir: "/app\n", want: "sets WORKDIR /app"}, + {name: "inspect fails", err: errors.New("daemon unavailable"), want: "Warning: couldn't read WORKDIR of source image example/trainer:v1: daemon unavailable"}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + stderr := &bytes.Buffer{} + ctx := cmdio.InContext(t.Context(), cmdio.NewIO(t.Context(), flags.OutputText, strings.NewReader(""), io.Discard, stderr, "", "")) + run := func(_ context.Context, _ io.Reader, out, _ io.Writer, _ string, args ...string) error { + assert.Equal(t, []string{"image", "inspect", "--format", "{{.Config.WorkingDir}}", "example/trainer:v1"}, args) + _, _ = io.WriteString(out, tt.workingDir) + return tt.err + } + warnImageWorkingDir(ctx, run, "docker", "example/trainer:v1", io.Discard) + if tt.want == "" { + assert.Empty(t, stderr.String()) + } else { + assert.Contains(t, stderr.String(), tt.want) + } + }) + } +} + func TestRegistryHostFromDockerConfigureOutput(t *testing.T) { output := `Configured Docker credential helper for 123.container.us-west-2.cloud.databricks.test Updated Docker config: /tmp/docker/config.json From d48fc7fc6d56d1d0cdfd3551be91b14c2e0df8f5 Mon Sep 17 00:00:00 2001 From: vinchenzo-db Date: Sat, 21 Nov 2026 04:29:18 +0000 Subject: [PATCH 4/6] air: read WORKDIR from the existing image inspect call Co-authored-by: Isaac --- cmd/air/image.go | 33 ++++---------- cmd/air/image_test.go | 100 +++++++++++++++++------------------------- 2 files changed, 49 insertions(+), 84 deletions(-) diff --git a/cmd/air/image.go b/cmd/air/image.go index 1e6be54392a..60c005ca23f 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -198,14 +198,18 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps cmdio.LogString(ctx, "Using local source image "+resolved.source) } - var platform bytes.Buffer - if err := deps.runCommand(ctx, nil, &platform, cmd.ErrOrStderr(), dockerPath, "image", "inspect", "--format", "{{.Os}}/{{.Architecture}}", resolved.source); err != nil { + var inspected bytes.Buffer + if err := deps.runCommand(ctx, nil, &inspected, cmd.ErrOrStderr(), dockerPath, "image", "inspect", "--format", "{{.Os}}/{{.Architecture}}|{{.Config.WorkingDir}}", resolved.source); err != nil { return fmt.Errorf("inspect source image %s: %w", resolved.source, err) } - if got := strings.TrimSpace(platform.String()); got != airImagePlatform { - return fmt.Errorf("source image %s has platform %q; AIR requires %s: use --pull to fetch a compatible image, or rebuild the source for %s", resolved.source, got, airImagePlatform, airImagePlatform) + platform, workingDir, _ := strings.Cut(strings.TrimSpace(inspected.String()), "|") + if platform != airImagePlatform { + return fmt.Errorf("source image %s has platform %q; AIR requires %s: use --pull to fetch a compatible image, or rebuild the source for %s", resolved.source, platform, airImagePlatform, airImagePlatform) + } + // AIR ignores WORKDIR at runtime; / is Docker's default and cannot break relative paths. + if workingDir != "" && workingDir != "/" { + cmdio.LogString(ctx, fmt.Sprintf("Warning: source image %s sets WORKDIR %s, which AI Runtime does not honor at runtime: use absolute paths in your command and scripts.", resolved.source, workingDir)) } - warnImageWorkingDir(ctx, deps.runCommand, dockerPath, resolved.source, cmd.ErrOrStderr()) cmdio.LogProgress(ctx, "Tagging image as "+target) if err := deps.runCommand(ctx, cmd.InOrStdin(), cmd.ErrOrStderr(), cmd.ErrOrStderr(), dockerPath, "tag", resolved.source, target); err != nil { @@ -369,25 +373,6 @@ func imageExistsLocally( return strings.TrimSpace(output.String()) != "", nil } -// warnImageWorkingDir warns when the source image sets WORKDIR, which AIR ignores at runtime. -// The check is advisory, so an inspect failure is reported but never blocks the push. -func warnImageWorkingDir( - ctx context.Context, - runCommand func(context.Context, io.Reader, io.Writer, io.Writer, string, ...string) error, - dockerPath, source string, - errOut io.Writer, -) { - var workingDir bytes.Buffer - if err := runCommand(ctx, nil, &workingDir, errOut, dockerPath, "image", "inspect", "--format", "{{.Config.WorkingDir}}", source); err != nil { - cmdio.LogString(ctx, fmt.Sprintf("Warning: couldn't read WORKDIR of source image %s: %v", source, err)) - return - } - // WORKDIR / is Docker's default and cannot break relative paths. - if dir := strings.TrimSpace(workingDir.String()); dir != "" && dir != "/" { - cmdio.LogString(ctx, fmt.Sprintf("Warning: source image %s sets WORKDIR %s, which AI Runtime does not honor at runtime: use absolute paths in your command and scripts.", source, dir)) - } -} - // runImageCommand runs a subprocess with the supplied context and I/O streams. func runImageCommand(ctx context.Context, in io.Reader, out, errOut io.Writer, executable string, args ...string) error { cmd := exec.CommandContext(ctx, executable, args...) diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index 8ad6203a2a3..43f53436b7a 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -56,10 +56,7 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { _, err := io.WriteString(out, "image-id\n") return err case "image inspect": - if args[3] == "{{.Config.WorkingDir}}" { - return nil - } - _, err := io.WriteString(out, "linux/amd64\n") + _, err := io.WriteString(out, "linux/amd64|\n") return err } return nil @@ -77,8 +74,7 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { target := "123.container.us-west-2.cloud.databricks.test/main.training.cuda:13.4.1" assert.Equal(t, []recordedImageCommand{ {executable: "/usr/bin/docker", args: []string{"image", "ls", "--quiet", "nvidia/cuda:13.4.1"}}, - {executable: "/usr/bin/docker", args: []string{"image", "inspect", "--format", "{{.Os}}/{{.Architecture}}", "nvidia/cuda:13.4.1"}}, - {executable: "/usr/bin/docker", args: []string{"image", "inspect", "--format", "{{.Config.WorkingDir}}", "nvidia/cuda:13.4.1"}}, + {executable: "/usr/bin/docker", args: []string{"image", "inspect", "--format", "{{.Os}}/{{.Architecture}}|{{.Config.WorkingDir}}", "nvidia/cuda:13.4.1"}}, {executable: "/usr/bin/docker", args: []string{"tag", "nvidia/cuda:13.4.1", target}}, {executable: "/usr/bin/docker", args: []string{"push", target}}, }, commands) @@ -93,67 +89,51 @@ func TestRunImagePushTagsAndPushesLocalImage(t *testing.T) { } func TestRunImagePushWarnsWhenImageSetsWorkingDir(t *testing.T) { - cmd, _, stderr := newImagePushTestCommand(t, "workspace") - deps := imagePushDeps{ - configureDocker: func(context.Context, string) (string, error) { - return "123.container.us-west-2.cloud.databricks.test", nil - }, - lookPath: func(string) (string, error) { return "docker", nil }, - runCommand: func(_ context.Context, _ io.Reader, out, _ io.Writer, _ string, args ...string) error { - switch { - case args[0] == "image" && args[1] == "ls": - _, err := io.WriteString(out, "image-id\n") - return err - case args[0] == "image" && args[1] == "inspect" && args[3] == "{{.Config.WorkingDir}}": - _, err := io.WriteString(out, "/app\n") - return err - case args[0] == "image" && args[1] == "inspect": - _, err := io.WriteString(out, "linux/amd64\n") - return err - } - return nil - }, - } - - err := runImagePush(cmd, &imagePushOptions{ - source: "example/trainer:v1", - catalog: "main", - schema: "training", - artifact: "trainer", - }, deps) - require.NoError(t, err) - - assert.Contains(t, stderr.String(), "Warning: source image example/trainer:v1 sets WORKDIR /app, which AI Runtime does not honor at runtime: use absolute paths in your command and scripts.") - assert.Contains(t, stderr.String(), "Pushed image") -} - -func TestWarnImageWorkingDir(t *testing.T) { tests := []struct { name string workingDir string - err error - want string + warn bool }{ - {name: "unset", workingDir: "\n", want: ""}, - {name: "root", workingDir: "/\n", want: ""}, - {name: "set", workingDir: "/app\n", want: "sets WORKDIR /app"}, - {name: "inspect fails", err: errors.New("daemon unavailable"), want: "Warning: couldn't read WORKDIR of source image example/trainer:v1: daemon unavailable"}, + {name: "unset", workingDir: ""}, + {name: "root", workingDir: "/"}, + {name: "set", workingDir: "/app", warn: true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - stderr := &bytes.Buffer{} - ctx := cmdio.InContext(t.Context(), cmdio.NewIO(t.Context(), flags.OutputText, strings.NewReader(""), io.Discard, stderr, "", "")) - run := func(_ context.Context, _ io.Reader, out, _ io.Writer, _ string, args ...string) error { - assert.Equal(t, []string{"image", "inspect", "--format", "{{.Config.WorkingDir}}", "example/trainer:v1"}, args) - _, _ = io.WriteString(out, tt.workingDir) - return tt.err + cmd, _, stderr := newImagePushTestCommand(t, "workspace") + deps := imagePushDeps{ + configureDocker: func(context.Context, string) (string, error) { + return "123.container.us-west-2.cloud.databricks.test", nil + }, + lookPath: func(string) (string, error) { return "docker", nil }, + runCommand: func(_ context.Context, _ io.Reader, out, _ io.Writer, _ string, args ...string) error { + switch strings.Join(args[:2], " ") { + case "image ls": + _, err := io.WriteString(out, "image-id\n") + return err + case "image inspect": + _, err := io.WriteString(out, "linux/amd64|"+tt.workingDir+"\n") + return err + } + return nil + }, } - warnImageWorkingDir(ctx, run, "docker", "example/trainer:v1", io.Discard) - if tt.want == "" { - assert.Empty(t, stderr.String()) + + err := runImagePush(cmd, &imagePushOptions{ + source: "example/trainer:v1", + catalog: "main", + schema: "training", + artifact: "trainer", + }, deps) + require.NoError(t, err) + + warning := "Warning: source image example/trainer:v1 sets WORKDIR /app, which AI Runtime does not honor at runtime: use absolute paths in your command and scripts." + if tt.warn { + assert.Contains(t, stderr.String(), warning) } else { - assert.Contains(t, stderr.String(), tt.want) + assert.NotContains(t, stderr.String(), "WORKDIR") } + assert.Contains(t, stderr.String(), "Pushed image") }) } } @@ -181,8 +161,8 @@ func TestRunImagePushPullsMissingImage(t *testing.T) { lookPath: func(string) (string, error) { return "docker", nil }, runCommand: func(_ context.Context, _ io.Reader, out, _ io.Writer, executable string, args ...string) error { commands = append(commands, recordedImageCommand{executable: executable, args: args}) - if args[0] == "image" && args[1] == "inspect" && args[3] != "{{.Config.WorkingDir}}" { - _, err := io.WriteString(out, "linux/amd64\n") + if args[0] == "image" && args[1] == "inspect" { + _, err := io.WriteString(out, "linux/amd64|\n") return err } return nil @@ -197,7 +177,7 @@ func TestRunImagePushPullsMissingImage(t *testing.T) { }, deps) require.NoError(t, err) - require.Len(t, commands, 6) + require.Len(t, commands, 5) assert.Equal(t, []string{"pull", "--platform", "linux/amd64", "example/image:v1"}, commands[1].args) } From 0f620d56e96a5138d0e8e7b176cd267cd6e1a757 Mon Sep 17 00:00:00 2001 From: vinchenzo-db Date: Sat, 21 Nov 2026 04:38:59 +0000 Subject: [PATCH 5/6] air: cover the WORKDIR warning in the image-push acceptance test Co-authored-by: Isaac --- acceptance/air/image-push/docker | 5 ++-- acceptance/air/image-push/output.txt | 34 ++++++++++++++++++++++------ acceptance/air/image-push/script | 4 ++++ 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/acceptance/air/image-push/docker b/acceptance/air/image-push/docker index 0303d011bdf..222adf7c5d6 100644 --- a/acceptance/air/image-push/docker +++ b/acceptance/air/image-push/docker @@ -18,8 +18,9 @@ case "$1 $2" in printf 'Docker inspect failed\n' >&2 exit 1 ;; - arm64) printf 'linux/arm64\n' ;; - *) printf 'linux/amd64\n' ;; + arm64) printf 'linux/arm64|\n' ;; + workdir) printf 'linux/amd64|/app\n' ;; + *) printf 'linux/amd64|\n' ;; esac ;; pull\ *) diff --git a/acceptance/air/image-push/output.txt b/acceptance/air/image-push/output.txt index 07d4a23b770..b44df80c2b3 100644 --- a/acceptance/air/image-push/output.txt +++ b/acceptance/air/image-push/output.txt @@ -31,7 +31,7 @@ Now you can set `environment.unity_catalog_image = my-catalog.my-schema.cuda:13. === docker commands image ls --quiet nvidia/cuda:13.4.1 -image inspect --format {{.Os}}/{{.Architecture}} nvidia/cuda:13.4.1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Config.WorkingDir}} nvidia/cuda:13.4.1 tag nvidia/cuda:13.4.1 [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 push [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 @@ -75,6 +75,22 @@ Pushed image. } } +=== image with WORKDIR warns but is pushed + +>>> databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training +Warning: This feature is in Preview. APIs may change, and the workspace must enable the Preview features. +Pushing example/image:v1 as main.training.image:v1 using profile docker-test +Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.localhost +Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json +Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks +Using local source image example/image:v1 +Warning: source image example/image:v1 sets WORKDIR /app, which AI Runtime does not honor at runtime: use absolute paths in your command and scripts. +Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +Docker push progress +Pushed image. +Now you can set `environment.unity_catalog_image = main.training.image:v1` in your YAML config and create a workload with `databricks air run -f config.yaml`. + === daemon failure must not pull >>> musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training @@ -193,25 +209,29 @@ Error: invalid image repository name: catalog.schema.artifact must be 255 charac === all docker commands image ls --quiet nvidia/cuda:13.4.1 -image inspect --format {{.Os}}/{{.Architecture}} nvidia/cuda:13.4.1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Config.WorkingDir}} nvidia/cuda:13.4.1 tag nvidia/cuda:13.4.1 [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 push [WORKSPACE_ID].container.us-west-2.localhost/my-catalog.my-schema.cuda:13.4.1-cudnn-devel-ubuntu26.04 image ls --quiet example/image:v1 pull --platform linux/amd64 example/image:v1 -image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Config.WorkingDir}} example/image:v1 tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 pull --platform linux/amd64 example/image:v1 -image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Config.WorkingDir}} example/image:v1 +tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 +image ls --quiet example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Config.WorkingDir}} example/image:v1 tag example/image:v1 [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 push [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 image ls --quiet example/image:v1 image ls --quiet example/image:v1 -image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Config.WorkingDir}} example/image:v1 image ls --quiet example/image:v1 -image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Config.WorkingDir}} example/image:v1 pull --platform linux/amd64 example/image:v1 -image inspect --format {{.Os}}/{{.Architecture}} example/image:v1 +image inspect --format {{.Os}}/{{.Architecture}}|{{.Config.WorkingDir}} example/image:v1 pull --platform linux/amd64 example/image:v1 === in a Claude Code session the auth docker configure child adds no install hint diff --git a/acceptance/air/image-push/script b/acceptance/air/image-push/script index a0343b728ab..fa41ce2ba9f 100644 --- a/acceptance/air/image-push/script +++ b/acceptance/air/image-push/script @@ -28,6 +28,10 @@ trace databricks air images push -p docker-test -s example/image:v1 --catalog ma # Parsing the complete stdout fails if Docker progress or human-readable text leaks into it. trace jq -e '{v, data}' "$HOME/result.json" +title "image with WORKDIR warns but is pushed" +export DOCKER_TEST_MODE=workdir +trace databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training + title "daemon failure must not pull" export DOCKER_TEST_MODE=daemon-error trace musterr databricks air images push -p docker-test -s example/image:v1 --catalog main --schema training From ec6a35c442693cc62cfaded9b047293856859f96 Mon Sep 17 00:00:00 2001 From: "v.chen" Date: Mon, 23 Nov 2026 21:46:47 +0000 Subject: [PATCH 6/6] air: drop the runtime claim from the WORKDIR warning The CLI shouldn't state how AI Runtime behaves, since the backend can change that. Say the image sets WORKDIR and that commands should use absolute paths. Co-authored-by: Isaac --- .nextchanges/air/images-push-workdir-warning.md | 2 +- acceptance/air/image-push/output.txt | 2 +- cmd/air/image.go | 4 ++-- cmd/air/image_test.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.nextchanges/air/images-push-workdir-warning.md b/.nextchanges/air/images-push-workdir-warning.md index c4bdfa267ba..304f3f2d54d 100644 --- a/.nextchanges/air/images-push-workdir-warning.md +++ b/.nextchanges/air/images-push-workdir-warning.md @@ -1 +1 @@ -* Warn in `databricks air images push` when the source image sets `WORKDIR`, which AI Runtime does not honor at runtime, so commands should use absolute paths. ([#7867](https://github.com/databricks/cli/pull/7867)) +* Warn in `databricks air images push` when the source image sets `WORKDIR`, so commands and scripts use absolute paths. ([#7867](https://github.com/databricks/cli/pull/7867)) diff --git a/acceptance/air/image-push/output.txt b/acceptance/air/image-push/output.txt index b44df80c2b3..901e894d519 100644 --- a/acceptance/air/image-push/output.txt +++ b/acceptance/air/image-push/output.txt @@ -84,7 +84,7 @@ Configured Docker credential helper for [WORKSPACE_ID].container.us-west-2.local Updated Docker config: [TEST_TMP_DIR]/home/docker/config.json Installed Docker credential helper: [TEST_TMP_DIR]/home/bin/docker-credential-databricks Using local source image example/image:v1 -Warning: source image example/image:v1 sets WORKDIR /app, which AI Runtime does not honor at runtime: use absolute paths in your command and scripts. +Warning: source image example/image:v1 sets WORKDIR /app; use absolute paths in your command and scripts. Tagging image as [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Pushing image to [WORKSPACE_ID].container.us-west-2.localhost/main.training.image:v1 Docker push progress diff --git a/cmd/air/image.go b/cmd/air/image.go index 60c005ca23f..f9fad63c510 100644 --- a/cmd/air/image.go +++ b/cmd/air/image.go @@ -206,9 +206,9 @@ func runImagePush(cmd *cobra.Command, opts *imagePushOptions, deps imagePushDeps if platform != airImagePlatform { return fmt.Errorf("source image %s has platform %q; AIR requires %s: use --pull to fetch a compatible image, or rebuild the source for %s", resolved.source, platform, airImagePlatform, airImagePlatform) } - // AIR ignores WORKDIR at runtime; / is Docker's default and cannot break relative paths. + // / is Docker's default WORKDIR and cannot break relative paths. if workingDir != "" && workingDir != "/" { - cmdio.LogString(ctx, fmt.Sprintf("Warning: source image %s sets WORKDIR %s, which AI Runtime does not honor at runtime: use absolute paths in your command and scripts.", resolved.source, workingDir)) + cmdio.LogString(ctx, fmt.Sprintf("Warning: source image %s sets WORKDIR %s; use absolute paths in your command and scripts.", resolved.source, workingDir)) } cmdio.LogProgress(ctx, "Tagging image as "+target) diff --git a/cmd/air/image_test.go b/cmd/air/image_test.go index 43f53436b7a..4403855a430 100644 --- a/cmd/air/image_test.go +++ b/cmd/air/image_test.go @@ -127,7 +127,7 @@ func TestRunImagePushWarnsWhenImageSetsWorkingDir(t *testing.T) { }, deps) require.NoError(t, err) - warning := "Warning: source image example/trainer:v1 sets WORKDIR /app, which AI Runtime does not honor at runtime: use absolute paths in your command and scripts." + warning := "Warning: source image example/trainer:v1 sets WORKDIR /app; use absolute paths in your command and scripts." if tt.warn { assert.Contains(t, stderr.String(), warning) } else {