Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "docker images ls" and "docker image ls"?

Tags:

docker

server

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:

  • https://docs.docker.com/engine/reference/commandline/image_ls/
  • https://docs.docker.com/engine/reference/commandline/images/
like image 471
SandOfTime Avatar asked Jan 08 '20 04:01

SandOfTime


People also ask

What does Docker image ls do?

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.

What is difference between Docker and Docker image?

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.

What is the difference between Docker PS and Docker container ls?

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.

What are the three main types of Docker components?

Docker follows Client-Server architecture, which includes the three main components that are Docker Client, Docker Host, and Docker Registry.


2 Answers

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.

like image 194
mozilla-firefox Avatar answered Oct 17 '22 16:10

mozilla-firefox


  • docker image ls lists images
  • docker 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 :)

like image 1
Max Avatar answered Oct 17 '22 18:10

Max