Skip to content

Commit bbabcc4

Browse files
authored
fix(standalone): resolve image LD_LIBRARY_PATH instead of literal shell var (#764)
Signed-off-by: Dorin Geman <dorin.geman@docker.com>
1 parent add135e commit bbabcc4

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

cmd/cli/pkg/standalone/containers.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,21 @@ func CreateControllerContainer(ctx context.Context, dockerClient *client.Client,
567567
ReadOnly: true,
568568
})
569569

570-
env = append(env, "LD_LIBRARY_PATH=/usr/lib/wsl/lib:/usr/local/cuda/lib64:${LD_LIBRARY_PATH}")
570+
// Prepend WSL and CUDA library paths to the image's existing LD_LIBRARY_PATH.
571+
// Docker does not perform shell expansion in env vars, so we must resolve
572+
// the image's value explicitly.
573+
ldLibPath := "/usr/lib/wsl/lib:/usr/local/cuda/lib64"
574+
if imgInfo, err := dockerClient.ImageInspect(ctx, imageName); err == nil {
575+
for _, e := range imgInfo.Config.Env {
576+
if strings.HasPrefix(e, "LD_LIBRARY_PATH=") {
577+
if v := strings.TrimPrefix(e, "LD_LIBRARY_PATH="); v != "" {
578+
ldLibPath += ":" + v
579+
}
580+
break
581+
}
582+
}
583+
}
584+
env = append(env, "LD_LIBRARY_PATH="+ldLibPath)
571585
config.Env = env
572586
}
573587

0 commit comments

Comments
 (0)