CodeBlanks Logo Icon CodeBlanks

Summary - Image management

Combine pull, tag, push and rmi to manage the image lifecycle.

Summary: image management

In this group:

  • docker images lists local images; <none> is a dangling image.
  • docker rmi deletes; it's refused if a container uses the image. image prune (-a) cleans in bulk.
  • docker pull downloads in layers; --platform and digests are supported.
  • For docker push, the name must include the account/registry and docker login must be done.
  • docker tag adds a new name; save/load move images without a registry.
docker pull nginx:alpine
docker tag nginx:alpine ali/nginx:alpine
docker push ali/nginx:alpine
docker image prune -f

Practice 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

terminal
# buraya yaz

Sample solution

terminal
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 -f

Expected 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.

Question
docker load ____ api.tar
Answer
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

All lessons in Beginner