do not pass user id on Windows system as engine is not able to handel it

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
Guillaume Lours 2025-07-22 11:50:01 +02:00 committed by Nicolas De loof
parent 8f91793fb5
commit 4d47da6dc2

View File

@ -23,6 +23,7 @@ import (
"os" "os"
"os/user" "os/user"
"path/filepath" "path/filepath"
"runtime"
"strconv" "strconv"
"github.com/compose-spec/compose-go/v2/types" "github.com/compose-spec/compose-go/v2/types"
@ -112,15 +113,20 @@ func convert(ctx context.Context, dockerCli command.Cli, model map[string]any, o
return err return err
} }
usr, err := user.Current() containerConfig := &container.Config{
if err != nil {
return err
}
created, err := dockerCli.Client().ContainerCreate(ctx, &container.Config{
Image: transformation, Image: transformation,
Env: []string{"LICENSE_AGREEMENT=true"}, Env: []string{"LICENSE_AGREEMENT=true"},
User: usr.Uid, }
}, &container.HostConfig{ // On POSIX systems, this is a decimal number representing the uid.
// On Windows, this is a security identifier (SID) in a string format and the engine isn't able to manage it
if runtime.GOOS != "windows" {
usr, err := user.Current()
if err != nil {
return err
}
containerConfig.User = usr.Uid
}
created, err := dockerCli.Client().ContainerCreate(ctx, containerConfig, &container.HostConfig{
AutoRemove: true, AutoRemove: true,
Binds: binds, Binds: binds,
}, &network.NetworkingConfig{}, nil, "") }, &network.NetworkingConfig{}, nil, "")