Reputation: 7996
I exported docker images in .tar format.
Then importing those images using K3S and ctr showed no results :
$ sudo k3s ctr i import myimage.tar
$
No output from import
cmd ?
$ sudo k3s ctr i ls
$
Nothing there....
Upvotes: 5
Views: 8363
Reputation: 895
I found out that in my case; I've created an image from image ID, not from tag. So when I want to import my image through ctr
, It cannot recognize the tag. So it could not create an image.
Let having a docker image like:
REPOSITORY TAG IMAGE ID CREATED SIZE
hel.lo/repopath/dev my-image 5b40ecbbea23 3 hours ago 230MB
So if you save the image with the below command, ctr
cannot create an image.
docker save 5b40ecbbea23 > my-image.tar
If you open the created tar file and look at the manifest.json file, you will see something like below(RepoTags is null):
[
{
"Config": "5b40ecbbea27ebdfbedabb732e228cb5649b0383ef6508257263978586cc8f9c.json",
"RepoTags": null,
"Layers": [...]
}
]
Once you save the image via below command, it could create an image:
docker save hel.lo/repopath/dev:my-image > my-image.tar
If you open the created tar file and look at the manifest.json file, you will see something like below(RepoTags is hel.lo/repopath/dev:my-image:my-image
):
[
{
"Config": "5b40ecbbea27ebdfbedabb732e228cb5649b0383ef6508257263978586cc8f9c.json",
"RepoTags": [
"hel.lo/repopath/dev:my-image:my-image"
],
"Layers": [...]
}
]
Upvotes: 5
Reputation: 7996
Adding --digest=true
worked for me :
$ sudo k3s ctr i import myimage.tar --digests=true
unpacking import-2021-05-19@sha256:f9952729292daa8d099c7bc3275f483fdb11ffa9bb1fc394bc06b44c101047e2 (sha256:f9952729292daa8d099c7bc3275f483fdb11ffa9bb1fc394bc06b44c101047e2)...done
And listing images also confirms that the importation has worked :
$ sudo k3s ctr i ls
...
import-2021-05-19@sha256:f99527292fa9bb1fc394bc06b44c101047e2 application/vnd.docker.distribution.manifest.v2+json sha256:f9952729292dac06b44c101047e2 939.9 MiB linux/amd64 io.cri-containerd.image=managed
Upvotes: 8