github.com/flavio/docker@v0.1.3-0.20170117145210-f63d1a6eec47/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/docker Github 8 repository at https://github.com/docker/docker/. 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 ``` 28 29 You can specify a `URL` or `-` (dash) to take data directly from `STDIN`. The 30 `URL` can point to an archive (.tar, .tar.gz, .tgz, .bzip, .tar.xz, or .txz) 31 containing a filesystem or to an individual file on the Docker host. If you 32 specify an archive, Docker untars it in the container relative to the `/` 33 (root). If you specify an individual file, you must specify the full path within 34 the host. To import from a remote location, specify a `URI` that begins with the 35 `http://` or `https://` protocol. 36 37 The `--change` option will apply `Dockerfile` instructions to the image 38 that is created. 39 Supported `Dockerfile` instructions: 40 `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR` 41 42 ## Examples 43 44 **Import from a remote location:** 45 46 This will create a new untagged image. 47 48 $ docker import http://example.com/exampleimage.tgz 49 50 **Import from a local file:** 51 52 Import to docker via pipe and `STDIN`. 53 54 $ cat exampleimage.tgz | docker import - exampleimagelocal:new 55 56 Import with a commit message. 57 58 $ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new 59 60 Import to docker from a local archive. 61 62 $ docker import /path/to/exampleimage.tgz 63 64 **Import from a local directory:** 65 66 $ sudo tar -c . | docker import - exampleimagedir 67 68 **Import from a local directory with new configurations:** 69 70 $ sudo tar -c . | docker import --change "ENV DEBUG true" - exampleimagedir 71 72 Note the `sudo` in this example – you must preserve 73 the ownership of the files (especially root ownership) during the 74 archiving with tar. If you are not root (or the sudo command) when you 75 tar, then the ownerships might not get preserved.