最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How do I run (not load) a Docker image that is a local tar file? - Stack Overflow

programmeradmin12浏览0评论

I have an image saved to disk as a .tar file. I would like to run this image as a container.

docker run take an image name, but I don't know what the name is; I only have a .tar file.

Is it possible to pass .tar directly to docker run? How?

I have an image saved to disk as a .tar file. I would like to run this image as a container.

docker run take an image name, but I don't know what the name is; I only have a .tar file.

Is it possible to pass .tar directly to docker run? How?

Share Improve this question asked Feb 5 at 10:49 sdgfsdhsdgfsdh 37.1k30 gold badges156 silver badges289 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can't do this directly; you must docker load the tar file first. Docker needs to import the image layers into its internal copy-on-write filesystem storage so that it can create the temporary container filesystem.

The other trick is finding the image name, if you don't already know it. This answer has a shell fragment using jq to extract the image name from JSON metadata embedded in the tar file.

So the best you can do is to load the image and then run it

docker load -i test_v1.0.tar
IMAGE=$(tar -xf test_v1.0.tar --to-stdout repositories | jq -r ".[\"${repository}\"] | keys | .[0]")
docker run ... "$IMAGE"
发布评论

评论列表(0)

  1. 暂无评论