What is the difference between docker images ls
and docker image ls
(with and without s (plural form))?
I'm confused about these two commands in Docker. docker images ls
is listing images in docker, what is the purpose of docker image ls
command?
Check the docs:
The docker image ls command takes an optional [REPOSITORY[:TAG]] argument that restricts the list to images that match the argument. If you specify REPOSITORY but no TAG, the docker image ls command lists all images in the given repository.
The key difference between a Docker image vs a container is that a Docker image is a template that defines how a container will be realized. A Docker container is a runtime instance of a Docker image. The purpose of this piece is to answer the question, what is a Docker image vs.
docker ps is shorthand that stands for "docker process status", whilst docker container ls is shorthand for the more verbose docker container list . As the accepted answer explains, there is no difference in how they work, and docker container ls is the 'newer' command, so you should probably prefer it.
Docker follows Client-Server architecture, which includes the three main components that are Docker Client, Docker Host, and Docker Registry.
docker images list
is not an alias to docker image list
, docker images
is. When calling docker images list
, it's the same as docker image list list
or docker image list --filter=reference=list
, which means filtering the image list with reference that are equal to list — and as you don't have any images containing list, it's returning an empty list. (Read this github discussion by vdemeester and many more https://github.com/docker/cli/issues/887 )
However, when you do docker images image_name
, what it does is, it returns all the parameters(list) of image image_name
i.e.
REPOSITORY TAG IMAGE ID CREATED SIZE
Earlier you were trying to have docker images ls
which means docker image ls ls
and the second ls is a list and not an image. Hence if you do docker images
it will list down all the images which means it is docker image ls
or docker image list
. I hope this makes it clear.
docker image ls
lists imagesdocker images xyz
lists images with the name xyz
. So you usually get empty list for a docker images ls
, because ls
is treated as name. By the way, we can use a wildcard docker images postgr*
. Reference: https://docs.docker.com/engine/reference/commandline/images/#list-images-by-name-and-tag
Well, yes, confusing :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With