- English
- English
Appearance
Appearance
In lesson 3, Docker Engine automatically pulled nginx:1.27 when the image was not available on the machine. Here you will manage images directly with Docker CLI: pull, tag, inspect, and remove them.
To pull an image from a registry without starting a container, use docker pull:
docker pull nginx:1.27
docker pull postgres:16To see images already available on the machine:
docker imagesThe columns you will check most often are REPOSITORY, TAG, and SIZE. SIZE shows the image's disk size. It does not automatically tell you whether the image is suitable for production.
Common format:
[registry/]name:tagExamples:
| Image | Meaning |
|---|---|
nginx:1.27 | Name nginx, tag 1.27, default registry (Docker Hub) |
postgres:16 | PostgreSQL major version 16 |
ghcr.io/org/api:1.4.2 | GHCR registry, org/api image, 1.4.2 tag |
A tag is a label attached to an image by its maintainer or creator. The contents of nginx:latest can be different today and next month.
To add another tag to an image, use docker tag. This command creates another name or tag that points to the same image. It does not create a new copy:
Command format:
docker tag <old-image>:<old-tag> <new-image>:<new-tag>Example:
docker tag my-app:latest my-app:v1.0To remove an image from the local machine, use docker rmi:
docker rmi nginx:1.27This command fails if a container, whether running or stopped, still uses the image. Remove the container first with docker rm, then run docker rmi.
To remove unused images, use:
docker image prune