From dd2f13bed4347e075da494c8635aa148baa5cd9d Mon Sep 17 00:00:00 2001 From: John Howard Date: Thu, 13 Sep 2018 10:56:01 -0700 Subject: [PATCH] LCOW: --platform on import (already in API) Signed-off-by: John Howard (cherry picked from commit b55a0b681fb9592da0de4b770b682d1493c73038) Signed-off-by: Sebastiaan van Stijn --- cli/command/image/import.go | 7 +++++-- docs/reference/commandline/import.md | 9 +++++++++ man/src/image/import.md | 8 ++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cli/command/image/import.go b/cli/command/image/import.go index cfa6a87b2dcb..2d2b7efc61d5 100644 --- a/cli/command/image/import.go +++ b/cli/command/image/import.go @@ -19,6 +19,7 @@ type importOptions struct { reference string changes dockeropts.ListOpts message string + platform string } // NewImportCommand creates a new `docker import` command @@ -43,6 +44,7 @@ func NewImportCommand(dockerCli command.Cli) *cobra.Command { options.changes = dockeropts.NewListOpts(nil) flags.VarP(&options.changes, "change", "c", "Apply Dockerfile instruction to the created image") flags.StringVarP(&options.message, "message", "m", "", "Set commit message for imported image") + command.AddPlatformFlag(flags, &options.platform) return cmd } @@ -71,8 +73,9 @@ func runImport(dockerCli command.Cli, options importOptions) error { } importOptions := types.ImageImportOptions{ - Message: options.message, - Changes: options.changes.GetAll(), + Message: options.message, + Changes: options.changes.GetAll(), + Platform: options.platform, } clnt := dockerCli.Client() diff --git a/docs/reference/commandline/import.md b/docs/reference/commandline/import.md index c520ef6324be..87eb8d06ad50 100644 --- a/docs/reference/commandline/import.md +++ b/docs/reference/commandline/import.md @@ -24,6 +24,7 @@ Options: -c, --change value Apply Dockerfile instruction to the created image (default []) --help Print usage -m, --message string Set commit message for imported image + --platform string Set platform if server is multi-platform capable ``` ## Description @@ -87,3 +88,11 @@ Note the `sudo` in this example – you must preserve the ownership of the files (especially root ownership) during the archiving with tar. If you are not root (or the sudo command) when you tar, then the ownerships might not get preserved. + +## When the daemon supports multiple operating systems +If the daemon supports multiple operating systems, and the image being imported +does not match the default operating system, it may be necessary to add +`--platform`. This would be necessary when importing a Linux image into a Windows +daemon. + + # docker import --platform=linux .\linuximage.tar diff --git a/man/src/image/import.md b/man/src/image/import.md index 2814a71e4323..1f18185cec05 100644 --- a/man/src/image/import.md +++ b/man/src/image/import.md @@ -38,5 +38,13 @@ This example sets the docker image ENV variable DEBUG to true by default. # tar -c . | docker image import -c="ENV DEBUG true" - exampleimagedir +## When the daemon supports multiple operating systems +If the daemon supports multiple operating systems, and the image being imported +does not match the default operating system, it may be necessary to add +`--platform`. This would be necessary when importing a Linux image into a Windows +daemon. + + # docker image import --platform=linux .\linuximage.tar + # See also **docker-export(1)** to export the contents of a filesystem as a tar archive to STDOUT.