Summary - Image management
- Docker & Kubernetes course
- Beginner
- Lesson 42/82
- 5 min
Combine pull, tag, push and rmi to manage the image lifecycle.
Summary: image management
In this group:
docker imageslists local images;<none>is a dangling image.docker rmideletes; it's refused if a container uses the image.image prune(-a) cleans in bulk.docker pulldownloads in layers;--platformand digests are supported.- For
docker push, the name must include the account/registry anddocker loginmust be done. docker tagadds a new name;save/loadmove images without a registry.
docker pull nginx:alpine
docker tag nginx:alpine ali/nginx:alpine
docker push ali/nginx:alpine
docker image prune -fPractice Release a version
Write four commands: tag the api:3.0.0 image as ali/api:3.0.0 and ali/api:latest (two commands); push all tags of the ali/api repository; clean up dangling images without confirmation.
Starter code
# buraya yazSample solution
docker tag api:3.0.0 ali/api:3.0.0
docker tag api:3.0.0 ali/api:latest
docker push --all-tags ali/api
docker image prune -fExpected output
The push refers to repository [docker.io/ali/api] 3.0.0: digest: sha256:4a5b… size: 1789 latest: digest: sha256:4a5b… size: 1789 Total reclaimed space: 0B
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 What is the way to move an image to a server without internet access?
- docker tag
- Write to tar with docker save and docker load on the server Correct answer
- docker push
- docker pull
Explanation: The tar file can be moved any way (scp, USB).
2 Load the image from a tar file.
docker load ____ api.tar
docker load -i api.tar
Explanation: -i (input) gives the file to read.
3 Match.
| Term | Meaning |
|---|---|
pull |
Download |
push |
Upload |
rmi |
Delete |
prune |
Bulk clean |