github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/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 applies `Dockerfile` instructions to the image that is
    32  created. Supported `Dockerfile` instructions:
    33  `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
    34  
    35  ## Examples
    36  
    37  ### Import from a remote location
    38  
    39  This 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  
    47  Import to docker via pipe and `STDIN`.
    48  
    49  ```console
    50  $ cat exampleimage.tgz | docker import - exampleimagelocal:new
    51  ```
    52  
    53  Import with a commit message.
    54  
    55  ```console
    56  $ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new
    57  ```
    58  
    59  Import 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  
    77  Note the `sudo` in this example – you must preserve
    78  the ownership of the files (especially root ownership) during the
    79  archiving with tar. If you are not root (or the sudo command) when you
    80  tar, then the ownerships might not get preserved.
    81  
    82  ## When the daemon supports multiple operating systems
    83  
    84  If the daemon supports multiple operating systems, and the image being imported
    85  does 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
    87  daemon.
    88  
    89  ```console
    90  $ docker import --platform=linux .\linuximage.tar
    91  ```