diff options
| author | Sebastiaan van Stijn <github@gone.nl> | 2022-01-25 12:23:05 +0100 |
|---|---|---|
| committer | Sebastiaan van Stijn <github@gone.nl> | 2022-01-25 15:23:11 +0100 |
| commit | cfddecc3d2031d80d796e5ee105ef72ba8ecf366 (patch) | |
| tree | 5bcb1d9a9a12c3c79efc9fb213207e37ea3f1864 /builder/dockerfile | |
| parent | 1ef0a5bb9187c2560115968509df339f87202b8a (diff) | |
| download | docker-cfddecc3d2031d80d796e5ee105ef72ba8ecf366.tar.gz | |
builder/dockerfile: remove leftover LCOW platform checks
This removes some of the checks that were added in 0cba7740d41369eee33b671f26276325580bc07b,
but should no longer be needed.
- `dockerfile.BuildFromConfig()` is used for `docker (container) commmit` and
`docker (image) import`. For `docker import`, we're failing early already.
For `commit`, it won't be possible to have a container that doesn't have the
right operating-system, so there's no need to validate.
- `dispatchRequest.getImageOrStage()`: simplify the check; all checks resulted
in an error on Windows, so it came down to "Windows does not support FROM scratch".
- `dispatchState.beginStage()`: `image.OperatingSystem()` already defaults to the
`runtime.GOOS` if unset, so remove the local default fallback.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'builder/dockerfile')
| -rw-r--r-- | builder/dockerfile/builder.go | 4 | ||||
| -rw-r--r-- | builder/dockerfile/dispatchers.go | 26 | ||||
| -rw-r--r-- | builder/dockerfile/dispatchers_test.go | 2 | ||||
| -rw-r--r-- | builder/dockerfile/evaluator.go | 4 |
4 files changed, 10 insertions, 26 deletions
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 + // Windows supports scratch. What is not supported is running containers from it. + if runtime.GOOS == "windows" { + return nil, errors.New("Windows does not support FROM scratch") } - 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. - 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)) - } + 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 } |
