mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
distribution: use the maximum compatible platform by default
When no specific platform is set, pull the platform that most matches the current host. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
fcc42d5682
commit
482d1d15bf
4 changed files with 23 additions and 3 deletions
|
@ -22,6 +22,7 @@ import (
|
|||
"github.com/opencontainers/selinux/go-selinux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
archvariant "github.com/tonistiigi/go-archvariant"
|
||||
)
|
||||
|
||||
type createOpts struct {
|
||||
|
@ -68,7 +69,7 @@ func (daemon *Daemon) containerCreate(opts createOpts) (containertypes.Container
|
|||
|
||||
if opts.params.Platform == nil && opts.params.Config.Image != "" {
|
||||
if img, _ := daemon.imageService.GetImage(opts.params.Config.Image, opts.params.Platform); img != nil {
|
||||
p := platforms.DefaultSpec()
|
||||
p := maximumSpec()
|
||||
imgPlat := v1.Platform{
|
||||
OS: img.OS,
|
||||
Architecture: img.Architecture,
|
||||
|
@ -319,3 +320,12 @@ func verifyNetworkingConfig(nwConfig *networktypes.NetworkingConfig) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// maximumSpec returns the distribution platform with maximum compatibility for the current node.
|
||||
func maximumSpec() v1.Platform {
|
||||
p := platforms.DefaultSpec()
|
||||
if p.Architecture == "amd64" {
|
||||
p.Variant = archvariant.AMD64Variant()
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import (
|
|||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
archvariant "github.com/tonistiigi/go-archvariant"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -1027,3 +1028,12 @@ func toOCIPlatform(p manifestlist.PlatformSpec) specs.Platform {
|
|||
OSVersion: p.OSVersion,
|
||||
}
|
||||
}
|
||||
|
||||
// maximumSpec returns the distribution platform with maximum compatibility for the current node.
|
||||
func maximumSpec() specs.Platform {
|
||||
p := platforms.DefaultSpec()
|
||||
if p.Architecture == "amd64" {
|
||||
p.Variant = archvariant.AMD64Variant()
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ func checkImageCompatibility(imageOS, imageOSVersion string) error {
|
|||
}
|
||||
|
||||
func withDefault(p specs.Platform) specs.Platform {
|
||||
def := platforms.DefaultSpec()
|
||||
def := maximumSpec()
|
||||
if p.OS == "" {
|
||||
p.OS = def.OS
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ require (
|
|||
github.com/spf13/pflag v1.0.5
|
||||
github.com/tchap/go-patricia v2.3.0+incompatible
|
||||
github.com/tonistiigi/fsutil v0.0.0-20220115021204-b19f7f9cb274
|
||||
github.com/tonistiigi/go-archvariant v1.0.0
|
||||
github.com/vbatts/tar-split v0.11.2
|
||||
github.com/vishvananda/netlink v1.1.1-0.20210330154013-f5de75959ad5
|
||||
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f
|
||||
|
@ -137,7 +138,6 @@ require (
|
|||
github.com/rexray/gocsi v1.2.2 // indirect
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
|
||||
github.com/tinylib/msgp v1.1.0 // indirect
|
||||
github.com/tonistiigi/go-archvariant v1.0.0 // indirect
|
||||
github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea // indirect
|
||||
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.2 // indirect
|
||||
|
|
Loading…
Reference in a new issue