github.com/45cali/docker@v1.11.1/docs/reference/commandline/import.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "import"
     4  description = "The import command description and usage"
     5  keywords = ["import, file, system, container"]
     6  [menu.main]
     7  parent = "smn_cli"
     8  +++
     9  <![end-metadata]-->
    10  
    11  # import
    12  
    13      Usage: docker import file|URL|- [REPOSITORY[:TAG]]
    14  
    15      Create an empty filesystem image and import the contents of the
    16  	tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then
    17  	optionally tag it.
    18  
    19        -c, --change=[]     Apply specified Dockerfile instructions while importing the image
    20        --help              Print usage
    21        -m, --message=      Set commit message for imported image
    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      $ docker import http://example.com/exampleimage.tgz
    43  
    44  **Import from a local file:**
    45  
    46  Import to docker via pipe and `STDIN`.
    47  
    48      $ cat exampleimage.tgz | docker import - exampleimagelocal:new
    49  
    50  Import with a commit message.
    51  
    52      $ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new
    53  
    54  Import to docker from a local archive.
    55  
    56      $ docker import /path/to/exampleimage.tgz
    57  
    58  **Import from a local directory:**
    59  
    60      $ sudo tar -c . | docker import - exampleimagedir
    61  
    62  **Import from a local directory with new configurations:**
    63  
    64      $ sudo tar -c . | docker import --change "ENV DEBUG true" - exampleimagedir
    65  
    66  Note the `sudo` in this example – you must preserve
    67  the ownership of the files (especially root ownership) during the
    68  archiving with tar. If you are not root (or the sudo command) when you
    69  tar, then the ownerships might not get preserved.