github.com/brahmaroutu/docker@v1.2.1-0.20160809185609-eb28dde01f16/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 ```markdown 14 Usage: docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]] 15 16 Import the contents from a tarball to create a filesystem image 17 18 Options: 19 -c, --change value Apply Dockerfile instruction to the created image (default []) 20 --help Print usage 21 -m, --message string Set commit message for imported image 22 ``` 23 24 You can specify a `URL` or `-` (dash) to take data directly from `STDIN`. The 25 `URL` can point to an archive (.tar, .tar.gz, .tgz, .bzip, .tar.xz, or .txz) 26 containing a filesystem or to an individual file on the Docker host. If you 27 specify an archive, Docker untars it in the container relative to the `/` 28 (root). If you specify an individual file, you must specify the full path within 29 the host. To import from a remote location, specify a `URI` that begins with the 30 `http://` or `https://` protocol. 31 32 The `--change` option will apply `Dockerfile` instructions to the image 33 that is created. 34 Supported `Dockerfile` instructions: 35 `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR` 36 37 ## Examples 38 39 **Import from a remote location:** 40 41 This will create a new untagged image. 42 43 $ docker import http://example.com/exampleimage.tgz 44 45 **Import from a local file:** 46 47 Import to docker via pipe and `STDIN`. 48 49 $ cat exampleimage.tgz | docker import - exampleimagelocal:new 50 51 Import with a commit message. 52 53 $ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new 54 55 Import to docker from a local archive. 56 57 $ docker import /path/to/exampleimage.tgz 58 59 **Import from a local directory:** 60 61 $ sudo tar -c . | docker import - exampleimagedir 62 63 **Import from a local directory with new configurations:** 64 65 $ sudo tar -c . | docker import --change "ENV DEBUG true" - exampleimagedir 66 67 Note the `sudo` in this example – you must preserve 68 the ownership of the files (especially root ownership) during the 69 archiving with tar. If you are not root (or the sudo command) when you 70 tar, then the ownerships might not get preserved.