docker ps | show image name instead of ID

1.2k Views Asked by At

When I run docker ps,it shows image IDs in the 2nd column: enter image description here But i want it to show image names: enter image description here what should I do ?

2

There are 2 best solutions below

3
On

Use this command to get image name : docker ps -a --format 'table {{.Image}}'

And this command for container name: docker ps -a --format 'table {{.Names}}'

0
On

It's probably because in the meantime the image name and tag was assigned to a different image.

reproduce:

docker pull ubuntu:22.04
docker tag ubuntu:22.04 myimage:mytag
docker run myimage:mytag

here if you do a docker ps -a you will see the container has myimage:mytag in the IMAGE column, however if you now tag a different image with this myimage:mytag:

docker pull debian:buster
docker tag debian:buster myimage:mytag

you will see the IMAGE ID in the IMAGE column of docker ps -a for the previous container because that tag doesn't belong to that image anymore.