简体   繁体   中英

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. I'm using Docker (not Docker toolbox) on OS X. I built the image from Dockerfile using the following command
sudo docker build -t myImage .

Docker confirmed that building was successful.
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.

You would be able to see your docker images by the below command:

docker images

And to check which all containers are running in docker:

docker ps -a

To get list of Images

docker image ls

or

docker images

Command to list the docker images is :

docker images

The default docker images will show all top level images, their repository and tags, and their size. 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. The link below does a good job explaining how the image layers are actually stored on disk.

https://docs.docker.com/storage/storagedriver/

As already said, after the docker images

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.

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. To do that you need to use the --load flag.

$ 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM