Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't find my Docker image after building it

Tags:

docker

macos

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.

like image 399
sean Avatar asked Jul 19 '16 17:07

sean


People also ask

Where is my docker image after build?

If you use the default storage driver overlay2, then your Docker images are stored in /var/lib/docker/overlay2 . There, you can find different files that represent read-only layers of a Docker image and a layer on top of it that contains your changes.

How do I find the docker image?

The easiest way to list Docker images is to use the “docker images” with no arguments. When using this command, you will be presented with the complete list of Docker images on your system. Alternatively, you can use the “docker image” command with the “ls” argument.

Where is my docker image windows?

If you want to access the image data directly, it's usually stored in the following locations: Linux: /var/lib/docker/ Windows: C:ProgramDataDockerDesktop. macOS: ~/Library/Containers/com.

How do I restore docker images?

Restore your dataUse docker pull to restore images you pushed to Docker Hub. If you backed up your images to a local tar file, use docker image load -i images. tar to restore previously saved images. Re-create your containers if needed, using docker run , or Docker Compose.


4 Answers

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
like image 129
Yogesh D Avatar answered Oct 12 '22 11:10

Yogesh D


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.

like image 27
thclark Avatar answered Oct 12 '22 11:10

thclark


To get list of Images

docker image ls

or

docker images
like image 3
Gurudath BN Avatar answered Oct 12 '22 11:10

Gurudath BN


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/

like image 1
Michael Avatar answered Oct 12 '22 10:10

Michael