github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/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  # import
     8  
     9  ```markdown
    10  Usage:  docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
    11  
    12  Import the contents from a tarball to create a filesystem image
    13  
    14  Options:
    15    -c, --change value     Apply Dockerfile instruction to the created image (default [])
    16        --help             Print usage
    17    -m, --message string   Set commit message for imported image
    18        --platform string  Set platform if server is multi-platform capable
    19  ```
    20  
    21  ## Description
    22  
    23  You 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)
    25  containing a filesystem or to an individual file on the Docker host.  If you
    26  specify 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
    28  the host. To import from a remote location, specify a `URI` that begins with the
    29  `http://` or `https://` protocol.
    30  
    31  The `--change` option will apply `Dockerfile` instructions to the image
    32  that is created.
    33  Supported `Dockerfile` instructions:
    34  `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
    35  
    36  ## Examples
    37  
    38  ### Import from a remote location
    39  
    40  This will create a new untagged image.
    41  
    42  ```bash
    43  $ docker import http://example.com/exampleimage.tgz
    44  ```
    45  
    46  ### Import from a local file
    47  
    48  - Import to docker via pipe and `STDIN`.
    49  
    50    ```bash
    51    $ cat exampleimage.tgz | docker import - exampleimagelocal:new
    52    ```
    53  
    54  - Import with a commit message.
    55  
    56    ```bash
    57    $ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new
    58    ```
    59  
    60  - Import to docker from a local archive.
    61  
    62    ```bash
    63    $ docker import /path/to/exampleimage.tgz
    64    ```
    65  
    66  ### Import from a local directory
    67  
    68  ```bash
    69  $ sudo tar -c . | docker import - exampleimagedir
    70  ```
    71  
    72  ### Import from a local directory with new configurations
    73  
    74  ```bash
    75  $ sudo tar -c . | docker import --change "ENV DEBUG=true" - exampleimagedir
    76  ```
    77  
    78  Note the `sudo` in this example – you must preserve
    79  the ownership of the files (especially root ownership) during the
    80  archiving with tar. If you are not root (or the sudo command) when you
    81  tar, then the ownerships might not get preserved.
    82  
    83  ## When the daemon supports multiple operating systems
    84  
    85  If the daemon supports multiple operating systems, and the image being imported
    86  does not match the default operating system, it may be necessary to add
    87  `--platform`. This would be necessary when importing a Linux image into a Windows
    88  daemon.
    89  
    90  ```bash
    91  $ docker import --platform=linux .\linuximage.tar
    92  ```