What is the difference between import and load in

2019-01-17 02:28发布

I understand the difference between export (for containers) and save (for images). But at the end of the day the tarball produced by either save or export should be used as an image.

So why are there 2 commands to make an image from a tarball?

1条回答
ゆ 、 Hurt°
2楼-- · 2019-01-17 03:34

docker save will indeed produce a tarball, but with all parent layers, and all tags + versions.

docker export does also produce a tarball, but without any layer/history.

It is often used when one wants to "flatten" an image, as illustrated in "Flatten a Docker container or image" from Thomas Uhrig:

docker export <CONTAINER ID> | docker import - some-image-name:latest

However, once those tarballs are produced, load/import are there to:

  • docker import creates one image from one tarball which is not even an image (just a filesystem you want to import as an image)

Create an empty filesystem image and import the contents of the tarball

  • docker load creates potentially multiple images from a tarred repository (since docker save can save multiple images in a tarball).

Loads a tarred repository from a file or the standard input stream

查看更多
登录 后发表回答