2015-06-21 16:41:38 -04:00
|
|
|
|
<!--[metadata]>
|
|
|
|
|
+++
|
|
|
|
|
title = "import"
|
|
|
|
|
description = "The import command description and usage"
|
|
|
|
|
keywords = ["import, file, system, container"]
|
|
|
|
|
[menu.main]
|
|
|
|
|
parent = "smn_cli"
|
|
|
|
|
+++
|
|
|
|
|
<![end-metadata]-->
|
|
|
|
|
|
|
|
|
|
# import
|
|
|
|
|
|
2015-07-25 08:07:24 -04:00
|
|
|
|
Usage: docker import file|URL|- [REPOSITORY[:TAG]]
|
2015-06-21 16:41:38 -04:00
|
|
|
|
|
|
|
|
|
Create an empty filesystem image and import the contents of the
|
|
|
|
|
tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then
|
|
|
|
|
optionally tag it.
|
|
|
|
|
|
|
|
|
|
-c, --change=[] Apply specified Dockerfile instructions while importing the image
|
2015-10-03 11:56:41 -04:00
|
|
|
|
--help=false Print usage
|
2015-08-20 00:01:50 -04:00
|
|
|
|
-m, --message= Set commit message for imported image
|
2015-06-21 16:41:38 -04:00
|
|
|
|
|
2015-07-25 08:07:24 -04:00
|
|
|
|
You can specify a `URL` or `-` (dash) to take data directly from `STDIN`. The
|
|
|
|
|
`URL` can point to an archive (.tar, .tar.gz, .tgz, .bzip, .tar.xz, or .txz)
|
2015-07-28 01:12:01 -04:00
|
|
|
|
containing a filesystem or to an individual file on the Docker host. If you
|
2015-07-25 08:07:24 -04:00
|
|
|
|
specify an archive, Docker untars it in the container relative to the `/`
|
|
|
|
|
(root). If you specify an individual file, you must specify the full path within
|
|
|
|
|
the host. To import from a remote location, specify a `URI` that begins with the
|
|
|
|
|
`http://` or `https://` protocol.
|
2015-06-21 16:41:38 -04:00
|
|
|
|
|
|
|
|
|
The `--change` option will apply `Dockerfile` instructions to the image
|
|
|
|
|
that is created.
|
|
|
|
|
Supported `Dockerfile` instructions:
|
|
|
|
|
`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
**Import from a remote location:**
|
|
|
|
|
|
|
|
|
|
This will create a new untagged image.
|
|
|
|
|
|
|
|
|
|
$ docker import http://example.com/exampleimage.tgz
|
|
|
|
|
|
|
|
|
|
**Import from a local file:**
|
|
|
|
|
|
|
|
|
|
Import to docker via pipe and `STDIN`.
|
|
|
|
|
|
|
|
|
|
$ cat exampleimage.tgz | docker import - exampleimagelocal:new
|
|
|
|
|
|
2015-10-08 10:20:06 -04:00
|
|
|
|
Import with a commit message
|
2015-08-20 00:01:50 -04:00
|
|
|
|
|
|
|
|
|
$ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new
|
|
|
|
|
|
2015-07-25 08:07:24 -04:00
|
|
|
|
Import to docker from a local archive.
|
|
|
|
|
|
|
|
|
|
$ docker import /path/to/exampleimage.tgz
|
|
|
|
|
|
2015-06-21 16:41:38 -04:00
|
|
|
|
**Import from a local directory:**
|
|
|
|
|
|
|
|
|
|
$ sudo tar -c . | docker import - exampleimagedir
|
|
|
|
|
|
|
|
|
|
**Import from a local directory with new configurations:**
|
|
|
|
|
|
|
|
|
|
$ sudo tar -c . | docker import --change "ENV DEBUG true" - exampleimagedir
|
|
|
|
|
|
|
|
|
|
Note the `sudo` in this example – you must preserve
|
|
|
|
|
the ownership of the files (especially root ownership) during the
|
|
|
|
|
archiving with tar. If you are not root (or the sudo command) when you
|
|
|
|
|
tar, then the ownerships might not get preserved.
|