diff --git a/builder/dockerfile/builder.go b/builder/dockerfile/builder.go index ac3ba16c72..f42bb1bc63 100644 --- a/builder/dockerfile/builder.go +++ b/builder/dockerfile/builder.go @@ -18,7 +18,6 @@ import ( "github.com/docker/docker/pkg/idtools" "github.com/docker/docker/pkg/streamformatter" "github.com/docker/docker/pkg/stringid" - "github.com/docker/docker/pkg/system" "github.com/moby/buildkit/frontend/dockerfile/instructions" "github.com/moby/buildkit/frontend/dockerfile/parser" "github.com/moby/buildkit/frontend/dockerfile/shell" @@ -319,9 +318,6 @@ func (b *Builder) dispatchDockerfileWithCancellation(parseResult []instructions. // // TODO: Remove? func BuildFromConfig(config *container.Config, changes []string, os string) (*container.Config, error) { - if !system.IsOSSupported(os) { - return nil, errdefs.InvalidParameter(system.ErrNotSupportedOperatingSystem) - } if len(changes) == 0 { return config, nil } diff --git a/builder/dockerfile/dispatchers.go b/builder/dockerfile/dispatchers.go index 66324a513e..1fafdc488c 100644 --- a/builder/dockerfile/dispatchers.go +++ b/builder/dockerfile/dispatchers.go @@ -246,27 +246,19 @@ func (d *dispatchRequest) getImageOrStage(name string, platform *specs.Platform) platform = d.builder.platform } - // Windows cannot support a container with no base image unless it is LCOW. + // Windows cannot support a container with no base image. if name == api.NoBaseImageSpecifier { - p := platforms.DefaultSpec() - if platform != nil { - p = *platform - } - imageImage := &image.Image{} - imageImage.OS = p.OS - - // old windows scratch handling - // TODO: scratch should not have an os. It should be nil image. - // Windows supports scratch. What is not supported is running containers - // from it. + // Windows supports scratch. What is not supported is running containers from it. if runtime.GOOS == "windows" { - if platform == nil || platform.OS == "linux" { - return nil, errors.New("Linux containers are not supported on this system") - } else if platform.OS == "windows" { - return nil, errors.New("Windows does not support FROM scratch") - } else { - return nil, errors.Errorf("platform %s is not supported", platforms.Format(p)) - } + return nil, errors.New("Windows does not support FROM scratch") + } + + // TODO: scratch should not have an os. It should be nil image. + imageImage := &image.Image{} + if platform != nil { + imageImage.OS = platform.OS + } else { + imageImage.OS = runtime.GOOS } return builder.Image(imageImage), nil } diff --git a/builder/dockerfile/dispatchers_test.go b/builder/dockerfile/dispatchers_test.go index 75ae30b52d..041fc39267 100644 --- a/builder/dockerfile/dispatchers_test.go +++ b/builder/dockerfile/dispatchers_test.go @@ -117,7 +117,7 @@ func TestFromScratch(t *testing.T) { err := initializeStage(sb, cmd) if runtime.GOOS == "windows" { - assert.Check(t, is.Error(err, "Linux containers are not supported on this system")) + assert.Check(t, is.Error(err, "Windows does not support FROM scratch")) return } diff --git a/builder/dockerfile/evaluator.go b/builder/dockerfile/evaluator.go index 02e1477528..1201eb320b 100644 --- a/builder/dockerfile/evaluator.go +++ b/builder/dockerfile/evaluator.go @@ -21,7 +21,6 @@ package dockerfile // import "github.com/docker/docker/builder/dockerfile" import ( "reflect" - "runtime" "strconv" "strings" @@ -216,9 +215,6 @@ func (s *dispatchState) beginStage(stageName string, image builder.Image) error s.stageName = stageName s.imageID = image.ImageID() s.operatingSystem = image.OperatingSystem() - if s.operatingSystem == "" { // In case it isn't set - s.operatingSystem = runtime.GOOS - } if !system.IsOSSupported(s.operatingSystem) { return system.ErrNotSupportedOperatingSystem }