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:
| Image | Container |
|---|---|
| A recipe (blueprint, template) | The cooked dish (the running thing) |
| Sits on disk, does nothing | Actually runs, uses CPU and RAM |
| One image can be reused | Many containers can come from the same image |
Created with docker build or docker pull | Created 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:
| Image | What it gives you |
|---|---|
nginx | A web server — great for testing HTTP things |
selenium/standalone-chrome | A full Chrome browser ready for Selenium tests |
mysql | A MySQL database — no installation needed |
openjdk:21 | Java 21 runtime — run your test JARs anywhere |
maven:3.9 | Maven + 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:
| Column | Meaning |
|---|---|
| REPOSITORY | The image name |
| TAG | The version |
| IMAGE ID | Unique identifier (short form of a longer hash) |
| SIZE | How 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
| Command | What it does |
|---|---|
docker pull nginx:1.25 | Download an image from Docker Hub |
docker images | List all images on your machine |
docker rmi nginx:1.25 | Remove a specific image |
docker image prune | Remove all unused images |
Next up: take those images and actually run them as containers.