How to remove the invalid <none> Docker mirror?

How to remove the invalid <none> Docker mirror?

before the start

Why is there noneso named in the mirror?
These images docker called dangling mirror , when the mirror is covered by the new image, the old version of the image name will become none.

The current docker host already exists nginx:latestmirror, and shortly after docker hubpushing a new version of nginx mirror.

When you re- docker pull nginx:latestdownload image, the old version is covered with mirrored names will be transformed intonone .

Another issue to note is introduced from the beginning docker 1.13.1 version docker imagecommand, a new command integrates list、rm、build、tag、push、pull, and other functions, to replace images 、build 、rmi 、tagand other two commands.

Considering the compatibility of the new version of the docker can still use these older two sub-commands, such as docker pull nginxwith docker image pull nginxtheir functions are the same.

We need to do is to find and delete these names with noneinvalid image.

Steps

  1. Lists with nonemirrored character
docker images -f dangling=true | head -n 3
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              d31c5d38836d        3 days ago          1.03GB
<none>              <none>              10d22b8d83b3        6 days ago          1.03GB

# 这两个命令功能相同
docker image ls -f dangling=true | head -n 3
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              d31c5d38836d        3 days ago          1.03GB
<none>              <none>              10d22b8d83b3        6 days ago          1.03GB
  1. Remove the invalid Mirror
docker image prune

WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Deleted Images:
deleted: sha256:d..省略..3e5c4918ee576d729a4b
# ...省略
  1. You can also use the command to delete rmi
docker rmi `docker image ls -f dangling=true -q`

Command Help

docker image

How to remove the invalid <none> Docker mirror?

docker rmi -h
Flag shorthand -h has been deprecated, please use --help

Usage:  docker rmi [OPTIONS] IMAGE [IMAGE...]

Remove one or more images

Options:
  -f, --force      Force removal of the image
      --no-prune   Do not delete untagged parents

summary

Finally, to sum up knowledge under article

  • Dangling mirror , when the mirror is covered by the new image, the old version of the image name will become none.
  • You can use docker image prunethe command to delete a mirror hanging pots.
  • For new students, although the old and the new command the same function, but it is recommended to use new commands to master.

Reference article

doker&k8s Qun [703906133]

Guess you like

Origin blog.51cto.com/14521173/2456053