docker import / docker image import
Description
Import the contents from a tarball to create a filesystem image
Usage
docker image import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
Extended description
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)
containing a filesystem or to an individual file on the Docker host. If you
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.
The --change
option will apply Dockerfile
instructions to the image
that is created.
Supported Dockerfile
instructions:
CMD
|ENTRYPOINT
|ENV
|EXPOSE
|ONBUILD
|USER
|VOLUME
|WORKDIR
For example uses of this command, refer to the examples section below.
Options
Name, shorthand | Default | Description |
--change , -c |
Apply Dockerfile instruction to the created image | |
--message , -m |
Set commit message for imported image | |
--platform |
experimental (daemon)API 1.32+ Set platform if server is multi-platform capable |
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
-
Import with a commit message.
$ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new
-
Import to docker from a local archive.
$ docker import /path/to/exampleimage.tgz
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.
Parent command
Command | Description |
---|---|
docker image | Manage images |
Related commands
Command | Description |
docker image build | Build an image from a Dockerfile |
docker image history | Show the history of an image |
docker image import | Import the contents from a tarball to create a filesystem image |
docker image inspect | Display detailed information on one or more images |
docker image load | Load an image from a tar archive or STDIN |
docker image ls | List images |
docker image prune | Remove unused images |
docker image pull | Pull an image or a repository from a registry |
docker image push | Push an image or a repository to a registry |
docker image rm | Remove one or more images |
docker image save | Save one or more images to a tar archive (streamed to STDOUT by default) |
docker image tag | Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE |