Docker Images

Pull, list, remove images — Docker Hub explained

Image vs Container

People often mix these two words up. Here is the simplest way to think about it:

ImageContainer
A recipe (blueprint, template)The cooked dish (the running thing)
Sits on disk, does nothingActually runs, uses CPU and RAM
One image can be reusedMany containers can come from the same image
Created with docker build or docker pullCreated with docker run

Think of it like a Java class vs an object. The class definition is the image. When you do new MyClass() you create a container — a live instance.

Docker Hub — The Image Supermarket

Docker Hub (hub.docker.com) is a public registry full of ready-made images. Think of it like Maven Central — instead of downloading JARs, you download images.

Some images you will use every day as a QA engineer:

ImageWhat it gives you
nginxA web server — great for testing HTTP things
selenium/standalone-chromeA full Chrome browser ready for Selenium tests
mysqlA MySQL database — no installation needed
openjdk:21Java 21 runtime — run your test JARs anywhere
maven:3.9Maven + Java — build and run tests in CI

Image Tags — Choose Your Version

Every image has a tag that specifies the version. You write it after a colon: image:tag.

nginx          # same as nginx:latest (not recommended)
nginx:1.25     # specific version (recommended)
openjdk:21     # Java 21
openjdk:17     # Java 17

Pulling an Image

docker pull downloads an image to your machine without running it.

docker pull nginx:1.25

Docker will show you a progress bar as it downloads each layer of the image:

1.25: Pulling from library/nginx
a480a496ba95: Pull complete
f3ace1b8ce45: Pull complete
...
Status: Downloaded newer image for nginx:1.25

Listing Your Images

See all images currently stored on your machine:

docker images

Output:

REPOSITORY    TAG       IMAGE ID       CREATED       SIZE
nginx         1.25      a480a496ba95   2 weeks ago   187MB
hello-world   latest    d2c94e258dcb   1 year ago    13.3kB

The columns tell you exactly what you need:

ColumnMeaning
REPOSITORYThe image name
TAGThe version
IMAGE IDUnique identifier (short form of a longer hash)
SIZEHow much disk space it uses

Removing an Image

Images sit on your disk forever until you remove them. Clean up with:

docker rmi nginx:1.25

You can also use the image ID instead of the name:

docker rmi a480a496ba95

To remove all unused images at once (a quick cleanup command):

docker image prune

Four Commands, That Is All

CommandWhat it does
docker pull nginx:1.25Download an image from Docker Hub
docker imagesList all images on your machine
docker rmi nginx:1.25Remove a specific image
docker image pruneRemove all unused images

Next up: take those images and actually run them as containers.