github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/docs/reference/commandline/import.md (about)

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