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.


Solution 1:

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

Solution 2:

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.