image_import
Imports a root filesystem tarball as a new Docker image without build history.
Instructions
Create an image from a flat root-filesystem tarball, like docker import.
Imports a filesystem archive as a new single-layer image with no build history — not the same
thing as image_load, which restores a docker save archive complete with its layers, tags and
history, so prefer image_load for anything image_save produced. Use this for a rootfs that
came from somewhere else: a container_export archive, a distro base tarball, a VM image dump.
The result has an empty config — no CMD/ENTRYPOINT/ENV — unless you supply changes, so an
imported image is usually not runnable until you set at least a command. Pass exactly one source
(from_file, data, from_url or from_image); ValueError otherwise. from_url and
from_image are fetched by the daemon, from_file/data are read here and uploaded; a
from_file path that is not a readable file raises rather than being retried as a URL. Unlike
the other image-creating tools this stamps no provenance labels: the Engine's import call accepts
no labels field, and changes does not cover LABEL.
args:
repository - Repository name to give the new image, e.g. "myorg/rootfs"; may include a tag
(myorg/rootfs:v1), and defaults to :latest when it does not. Omit to import untagged,
addressable only by the id in the returned progress (omit it entirely -- a blank string
is a ValueError, not a shorthand for untagged). A digest reference is refused by the
daemon. Required if tag is given
tag - Tag to apply, e.g. "v1". Overrides a tag already in repository rather than being
ignored, so passing repository="myorg/rootfs:v1" with tag="v2" yields :v2. Requires
repository (ValueError without it — the daemon would otherwise silently drop the tag
and import untagged). Blank is also a ValueError, not a shorthand for the default: the
daemon would substitute latest without saying so
from_file - Path to a rootfs tarball on the server host (~ expanded), read by the server's
user; FileNotFoundError if it is not an existing regular file; exactly one source
data - Rootfs tarball contents in band (base64-encoded by MCP, so prefer from_file for
anything but small archives); exactly one source
from_url - URL the daemon fetches the tarball from; exactly one source
from_image - Name of an existing image to import from, like a Dockerfile FROM; exactly one
source
changes - Dockerfile instructions applied to the new image, e.g. ['CMD ["/bin/sh"]']; only
CMD, ENTRYPOINT, ENV, EXPOSE, ONBUILD, USER, VOLUME and WORKDIR are supported. Parsed
as real Dockerfile syntax, so shell form is wrapped exactly as a Dockerfile would wrap
it (CMD /bin/sh is stored as ["/bin/sh","-c","/bin/sh"]) — use the exec form
CMD ["/bin/sh"] to store a bare argv
returns: str - The daemon's raw newline-delimited JSON progress records; the final record carries
the new image id as its status
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tag | No | ||
| data | No | ||
| changes | No | ||
| from_url | No | ||
| from_file | No | ||
| from_image | No | ||
| repository | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |