57

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.

Community
  • 1
  • 1
sean
  • 1,632
  • 2
  • 15
  • 34
  • 1
    Do you actually need to know where the image is stored on the filesystem, or do you just want to check that Docker knows about it? For the latter, just run `docker images`. – jwodder Jul 19 '16 at 17:08
  • 2
    For the former, it's going to be in the docker host VM filesystem. – ldg Jul 19 '16 at 21:38
  • 1
    Look into ```docker save``` and ```docker load``` which allows you to save the image to a tar and load it again somewhere else. That way you have a tangeble actual image that you can move around with you from machine to machine. – OpenBSDNinja Sep 26 '19 at 13:08
  • Does this answer your question? [How to list containers in Docker](https://stackoverflow.com/questions/16840409/how-to-list-containers-in-docker) – Murtaza Haji Jun 30 '20 at 19:49

6 Answers6

44

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
KRP
  • 38
  • 5
Yogesh D
  • 1,558
  • 14
  • 29
  • 25
    Where is the location of the image files? – WestCoastProjects Jan 31 '17 at 17:29
  • 1
    If all you need is an archive of the image, you can use [docker save](https://docs.docker.com/engine/reference/commandline/save/) like so `docker save myimage:tag | gzip > myimage_tag.tar.gz`. You can list your local images with `docker image ls`. – Eirik H Jan 28 '22 at 14:22
13

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.

thclark
  • 4,784
  • 3
  • 39
  • 65
  • 1
    I noticed this is happening to me now too and didn't used to. I wonder if something changed? – vmayer Jun 03 '22 at 03:41
  • You may have updated to a more recent version of docker. I believe at some point they changed to using buildkit by default (don't quote me, though) – thclark Jun 03 '22 at 11:03
3

To get list of Images

docker image ls

or

docker images
Viktor
  • 2,623
  • 3
  • 19
  • 28
Gurudath BN
  • 1,391
  • 20
  • 21
1

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/

Michael
  • 546
  • 1
  • 7
  • 19
1

As already said, after the docker images

this command will show you all the images you have locally.

i.e "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.

Nisarg
  • 1,631
  • 6
  • 19
  • 31
basquiatraphaeu
  • 525
  • 7
  • 19
0

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

Nobita
  • 598
  • 3
  • 6
  • 16