...

Text file src/github.com/docker/cli/docs/reference/commandline/image_import.md

Documentation: github.com/docker/cli/docs/reference/commandline

     1# import
     2
     3<!---MARKER_GEN_START-->
     4Import the contents from a tarball to create a filesystem image
     5
     6### Aliases
     7
     8`docker image import`, `docker import`
     9
    10### Options
    11
    12| Name              | Type     | Default | Description                                       |
    13|:------------------|:---------|:--------|:--------------------------------------------------|
    14| `-c`, `--change`  | `list`   |         | Apply Dockerfile instruction to the created image |
    15| `-m`, `--message` | `string` |         | Set commit message for imported image             |
    16| `--platform`      | `string` |         | Set platform if server is multi-platform capable  |
    17
    18
    19<!---MARKER_GEN_END-->
    20
    21## Description
    22
    23You can specify a `URL` or `-` (dash) to take data directly from `STDIN`. The
    24`URL` can point to an archive (.tar, .tar.gz, .tgz, .bzip, .tar.xz, or .txz)
    25containing a filesystem or to an individual file on the Docker host.  If you
    26specify an archive, Docker untars it in the container relative to the `/`
    27(root). If you specify an individual file, you must specify the full path within
    28the host. To import from a remote location, specify a `URI` that begins with the
    29`http://` or `https://` protocol.
    30
    31The `--change` option applies `Dockerfile` instructions to the image that is
    32created. Supported `Dockerfile` instructions:
    33`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
    34
    35## Examples
    36
    37### Import from a remote location
    38
    39This creates a new untagged image.
    40
    41```console
    42$ docker import https://example.com/exampleimage.tgz
    43```
    44
    45### Import from a local file
    46
    47Import to docker via pipe and `STDIN`.
    48
    49```console
    50$ cat exampleimage.tgz | docker import - exampleimagelocal:new
    51```
    52
    53Import with a commit message.
    54
    55```console
    56$ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new
    57```
    58
    59Import to docker from a local archive.
    60
    61```console
    62$ docker import /path/to/exampleimage.tgz
    63```
    64
    65### Import from a local directory
    66
    67```console
    68$ sudo tar -c . | docker import - exampleimagedir
    69```
    70
    71### Import from a local directory with new configurations
    72
    73```console
    74$ sudo tar -c . | docker import --change "ENV DEBUG=true" - exampleimagedir
    75```
    76
    77Note the `sudo` in this example – you must preserve
    78the ownership of the files (especially root ownership) during the
    79archiving with tar. If you are not root (or the sudo command) when you
    80tar, then the ownerships might not get preserved.
    81
    82## When the daemon supports multiple operating systems
    83
    84If the daemon supports multiple operating systems, and the image being imported
    85does not match the default operating system, it may be necessary to add
    86`--platform`. This would be necessary when importing a Linux image into a Windows
    87daemon.
    88
    89```console
    90$ docker import --platform=linux .\linuximage.tar
    91```

View as plain text