Docker image load vs. import

What is the difference between docker load and docker import? Both seem to serve the same purpose, more exactly load an image from a tar archive.

Thx

ā€œloadā€ loads an actual image from a tar file, while ā€œimportā€ just imports the filesystem into a new image without any image metadata. So if you export an image, that only exports its filesystem. It is like copying out the files from a container started from that image. But no metadata will be kept, so you will lose the entrypoint definition, the command, labels, environment variables and port definitions (after the EXPOSE instruction).

Personally I have never needed export and import, only when I was wondering about what it was for. In every other case, docker image save and docker image load is what we need to save and load images when we don’t have registry or we have to copy images to a server without internet connection.

1 Like

Hej @rimelek thx for the answer, I’m having a small issue with load, in a vanilla situation (docker save followed by docker load) the image is loaded and can be use without any issues, but if I do a docker save, extract archive, modify the config blob and then recreate the archive and docker load -i new.tar the image is loaded but I cannot use it, i.e. docker run gives Unable to find image ... locally and if I inspect the image I can see it does not have any RootFS. Any idea?

Why do you even try to manually edit the files of an exported image? Images have a special structure, you cannot just easily edit them without using Docker commands. If you want to change an image, the right way is using it as a base image for a new image and you can add anything to your new layers or virtually delete files so it is not visible in your new image.

It was for didactic purposes, it works now, but I had to recalculate the hash of the modified config blob. Thx