Bird
Raised Fist0
Dockerdevops~3 mins

Listing local images in Docker - Commands & Configuration

Choose your learning style10 modes available
Introduction
Sometimes you need to see which Docker images are saved on your computer. Listing local images helps you find images you can use to create containers or clean up space.
When you want to check if an image is already downloaded before running a container
When you need to find the image ID to remove or tag an image
When you want to see all versions of an image you have locally
When you want to verify that your image build was successful and saved
When you want to clean up unused images to free disk space
Commands
This command lists all Docker images stored locally on your machine with their repository name, tag, image ID, creation date, and size.
Terminal
docker images
Expected OutputExpected
REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 4bb46517cac3 2 weeks ago 133MB ubuntu 20.04 1d622ef86b13 3 weeks ago 72.9MB
→
-a - Show all images (default shows just latest tags)
→
--digests - Show image digests
This is an alternative command to list local images. It works the same as 'docker images' and is part of the newer Docker CLI syntax.
Terminal
docker image ls
Expected OutputExpected
REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 4bb46517cac3 2 weeks ago 133MB ubuntu 20.04 1d622ef86b13 3 weeks ago 72.9MB
Key Concept

If you remember nothing else from this pattern, remember: use 'docker images' or 'docker image ls' to see all Docker images saved on your computer.

Common Mistakes
Typing 'docker image' without 'ls' or 'images'
The command is incomplete and will show an error because it expects a subcommand like 'ls' or 'rm'.
Use 'docker image ls' or 'docker images' to list images.
Expecting 'docker images' to show running containers
'docker images' only lists images, not containers. Containers are different and require 'docker ps'.
Use 'docker ps' to list running containers.
Summary
Use 'docker images' or 'docker image ls' to list all local Docker images.
The output shows repository, tag, image ID, creation time, and size.
Flags like '-a' show all images including intermediate ones.

Practice

(1/5)
1. What does the docker images command do?
easy
A. Lists all local Docker images stored on your machine
B. Shows running Docker containers
C. Deletes all Docker images
D. Builds a new Docker image from a Dockerfile

Solution

  1. Step 1: Understand the purpose of docker images

    This command is designed to show all Docker images saved locally on your computer.
  2. Step 2: Differentiate from other Docker commands

    Commands like docker ps show running containers, and docker build creates images, so they are not correct here.
  3. Final Answer:

    Lists all local Docker images stored on your machine -> Option A
  4. Quick Check:

    docker images = list local images [OK]
Hint: Remember: images = saved pictures, containers = running apps [OK]
Common Mistakes:
  • Confusing images with running containers
  • Thinking it deletes images
  • Mixing it up with build command
2. Which of these is the correct syntax to list all local Docker images?
easy
A. docker list images
B. docker image list -a
C. docker show images
D. docker images

Solution

  1. Step 1: Recall the exact command for listing images

    The standard command is docker images to list local images.
  2. Step 2: Check other options for correctness

    docker list images and docker show images are invalid commands. docker image list -a is a valid command but lists all images including intermediate layers, which is more advanced than the basic listing.
  3. Final Answer:

    docker images -> Option D
  4. Quick Check:

    Correct syntax = docker images [OK]
Hint: Use exact command: docker images, no extra words [OK]
Common Mistakes:
  • Adding extra words like 'list' or 'show'
  • Using incorrect flags or subcommands
  • Confusing 'image' and 'images'
3. What will be the output of the command docker images if you have two images named app with tags v1 and v2?
medium
A. It will list images but without tags
B. It will list only the latest image
C. It will list both images with their tags and IDs
D. It will show an error about duplicate image names

Solution

  1. Step 1: Understand how Docker images are listed

    The docker images command shows all images, including multiple tags for the same image name.
  2. Step 2: Confirm output details

    Both images named app with tags v1 and v2 will appear separately with their tags and image IDs.
  3. Final Answer:

    It will list both images with their tags and IDs -> Option C
  4. Quick Check:

    docker images lists all tags separately [OK]
Hint: Each tag is a separate image entry in the list [OK]
Common Mistakes:
  • Assuming only one tag shows
  • Expecting an error for duplicate names
  • Thinking tags are hidden
4. You ran docker images -l but got an error. What is the problem?
medium
A. The -l flag is invalid for docker images
B. You need to run the command as root
C. You must specify an image name with -l
D. The Docker daemon is not running

Solution

  1. Step 1: Check the meaning of -l flag

    The -l flag is not a valid option for docker images. It causes a syntax error.
  2. Step 2: Consider other possible causes

    Running as root or daemon status would cause different errors. The -l flag does not require an image name.
  3. Final Answer:

    The -l flag is invalid for docker images -> Option A
  4. Quick Check:

    Invalid flag = error [OK]
Hint: Use only supported flags with docker images [OK]
Common Mistakes:
  • Assuming -l lists latest images
  • Thinking root permission fixes flag errors
  • Confusing daemon errors with syntax errors
5. You want to list all local Docker images but only show the repository and tag columns. Which command should you use?
hard
A. docker images --filter "repository,tag"
B. docker images --format "{{.Repository}}:{{.Tag}}"
C. docker images --only repository tag
D. docker images --columns repository tag

Solution

  1. Step 1: Understand formatting option in docker images

    The --format flag lets you customize output columns using Go template syntax.
  2. Step 2: Check each option's validity

    --format "{{.Repository}}:{{.Tag}}" correctly formats output to show only repository and tag. Other options are invalid or unsupported.
  3. Final Answer:

    docker images --format "{{.Repository}}:{{.Tag}}" -> Option B
  4. Quick Check:

    Use --format with Go templates for custom columns [OK]
Hint: Use --format with {{.Repository}} and {{.Tag}} [OK]
Common Mistakes:
  • Using unsupported flags like --only or --columns
  • Confusing --filter with formatting
  • Incorrect template syntax
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard