[英]I can't find my Docker image after building it
I'm new to Docker, so please allow me to describe the steps that I did.我是 Docker 新手,所以请允许我描述一下我所做的步骤。 I'm using Docker (not Docker toolbox) on OS X. I built the image from Dockerfile using the following command我在 OS X 上使用 Docker(不是 Docker 工具箱)。我使用以下命令从 Dockerfile 构建了图像sudo docker build -t myImage .
Docker confirmed that building was successful. Docker 确认构建成功。
Successfully built 7240e.....
However, I can't find the image anywhere.但是,我在任何地方都找不到图像。 I looked at this question , but the answer is for Docker toolbox, and I don't have a folder /Users/<username>/.docker
as suggested by the accepted answer.我查看了这个问题,但答案是针对 Docker 工具箱的,并且我没有接受的答案所建议的文件夹/Users/<username>/.docker
。
You would be able to see your docker images by the below command:您将能够通过以下命令查看您的 docker 图像:
docker images
And to check which all containers are running in docker:并检查哪些所有容器都在 docker 中运行:
docker ps -a
To get list of Images获取图像列表
docker image ls
or或
docker images
Command to list the docker images is :列出 docker 镜像的命令是:
docker images
The default docker images will show all top level images, their repository and tags, and their size.默认的 docker 镜像将显示所有顶级镜像、它们的存储库和标签以及它们的大小。 An image will be listed more than once if it has multiple repository names or tags.如果一个图像有多个存储库名称或标签,它将被多次列出。
Click here for the screenshot for more details单击此处获取屏幕截图以了解更多详细信息
In addition to the correct responses above that discuss how to access your container or container image, if you want to know how the image is written to disk...除了上面讨论如何访问容器或容器映像的正确响应之外,如果您想知道映像是如何写入磁盘的...
Docker uses a Copy on Write File System ( https://en.wikipedia.org/wiki/Copy-on-write ) and stores each Docker image as a series of read only layers and stores them in a list. Docker 使用写时复制文件系统 ( https://en.wikipedia.org/wiki/Copy-on-write ) 并将每个 Docker 映像存储为一系列只读层并将它们存储在列表中。 The link below does a good job explaining how the image layers are actually stored on disk.下面的链接很好地解释了图像层是如何实际存储在磁盘上的。
https://docs.docker.com/storage/storagedriver/ https://docs.docker.com/storage/storagedriver/
As already said, after the docker images如前所述,在docker 镜像之后
this command will show you all the images you have locally.此命令将显示您在本地拥有的所有图像。
ie "somth like that"即“像那样”
REPOSITORY TAG IMAGE ID CREATED SIZE
codestandars 1.0 a22daacf6761 8 minutes ago 622MB
bulletinboard 1.0 b73e8e68edc0 2 hours ago 681MB
ubuntu 18.04 cf0f3ca922e0 4 days ago 64.2MB
now you should现在你应该
docker run -it
and the IMAGE ID or the TAG related to the repository you want to run. docker run -it
以及与您要运行的存储库相关的 IMAGE ID 或 TAG。
Local builds (in my case using buildkit) will create and cache the image layers but simply leave them in the cache rather than tell the docker daemon they're an actual image.本地构建(在我的情况下使用 buildkit)将创建和缓存图像层,但只是将它们留在缓存中,而不是告诉 docker 守护进程它们是实际图像。 To do that you need to use the --load
flag.为此,您需要使用--load
标志。
$ docker buildx build -t myImage .
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
Doesn't show anything, but...什么都没有显示,但是...
$ docker buildx build -t myImage --load .
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myImage latest 538021e3d342 18 minutes ago 190MB
And there it is!它就在那里!
There actually is a warning about this in the output of the build command... but it's above all the build step logs so vanishes off your terminal without easily being seen.在构建命令的输出中实际上有一个警告......但它首先是构建步骤日志,因此会从您的终端消失而不会轻易被发现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.