diff --git a/cli/command/image/build.go b/cli/command/image/build.go index d67ddfe9ff65..6fdd7907bf63 100644 --- a/cli/command/image/build.go +++ b/cli/command/image/build.go @@ -63,6 +63,7 @@ type buildOptions struct { target string imageIDFile string stream bool + platform string } // dockerfileFromStdin returns true when the user specified that the Dockerfile @@ -143,6 +144,8 @@ func NewBuildCommand(dockerCli command.Cli) *cobra.Command { flags.SetAnnotation("stream", "experimental", nil) flags.SetAnnotation("stream", "version", []string{"1.31"}) + flags.StringVar(&options.platform, "platform", "", "Set platform if server is multi-platform capable") + flags.SetAnnotation("platform", "version", []string{"1.30"}) return cmd } @@ -372,6 +375,7 @@ func runBuild(dockerCli command.Cli, options buildOptions) error { ExtraHosts: options.extraHosts.GetAll(), Target: options.target, RemoteContext: remote, + Platform: options.platform, } if s != nil { diff --git a/vendor/github.com/docker/docker/api/common.go b/vendor/github.com/docker/docker/api/common.go index 859daf602cc7..6e462aeda7a6 100644 --- a/vendor/github.com/docker/docker/api/common.go +++ b/vendor/github.com/docker/docker/api/common.go @@ -15,7 +15,7 @@ import ( // Common constants for daemon and client. const ( // DefaultVersion of Current REST API - DefaultVersion string = "1.31" + DefaultVersion string = "1.32" // NoBaseImageSpecifier is the symbol used by the FROM // command to specify that no base image is to be used. diff --git a/vendor/github.com/docker/docker/api/types/client.go b/vendor/github.com/docker/docker/api/types/client.go index 18a1263f10fa..6b2aba5c9e9d 100644 --- a/vendor/github.com/docker/docker/api/types/client.go +++ b/vendor/github.com/docker/docker/api/types/client.go @@ -179,10 +179,7 @@ type ImageBuildOptions struct { ExtraHosts []string // List of extra hosts Target string SessionID string - - // TODO @jhowardmsft LCOW Support: This will require extending to include - // `Platform string`, but is ommited for now as it's hard-coded temporarily - // to avoid API changes. + Platform string } // ImageBuildResponse holds information diff --git a/vendor/github.com/docker/docker/client/image_build.go b/vendor/github.com/docker/docker/client/image_build.go index 44a215f900f5..9292976eb079 100644 --- a/vendor/github.com/docker/docker/client/image_build.go +++ b/vendor/github.com/docker/docker/client/image_build.go @@ -124,5 +124,12 @@ func (cli *Client) imageBuildOptionsToQuery(options types.ImageBuildOptions) (ur query.Set("session", options.SessionID) } + if options.Platform != "" { + if err := cli.NewVersionError("1.32", "platform"); err != nil { + return query, err + } + query.Set("platform", options.Platform) + } + return query, nil }