Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.09] backport LCOW: --platform on import (already in API) #1375

Merged
merged 1 commit into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cli/command/image/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type importOptions struct {
reference string
changes dockeropts.ListOpts
message string
platform string
}

// NewImportCommand creates a new `docker import` command
Expand All @@ -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
}
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 9 additions & 0 deletions docs/reference/commandline/import.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
8 changes: 8 additions & 0 deletions man/src/image/import.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.