镜像以及仓库

搜索镜像

//-f STARS=3000 搜索 STARS 大于 300
[root@localhost ~]# docker search mysql -f STARS=3000
NAME      DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
mysql     MySQL is a widely used, open-source relation…   14043     [OK]
mariadb   MariaDB Server is a high performing open sou…   5357      [OK]

下载镜像

[root@localhost ~]# docker pull centos
Using default tag: latest
latest: Pulling from library/centos
a1d0c7532777: Pull complete
Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest

下载指定的标签tag

docker pull centos:8.3.2011
[root@localhost /]# docker pull centos:8.3.2011
8.3.2011: Pulling from library/centos
Digest: sha256:5528e8b1b1719d34604c87e11dcd1c0a20bedf46e83b5632cdeac91b8c04efc1
Status: Downloaded newer image for centos:8.3.2011
docker.io/library/centos:8.3.2011

查看本地镜像

[root@localhost ~]# docker images
REPOSITORY                                  TAG            IMAGE ID       CREATED         SIZE
registry.sim.scutbot.cn/simulatorx/2023ul   beta-1.1.1.5   b6e6318c172b   2 weeks ago     940MB
minio/minio                                 latest         c5442c4190b8   2 months ago    254MB
whyour/qinglong                             2.10.13        5997b3824cbe   15 months ago   434MB
centos                                      latest         5d0da3dc9764   19 months ago   231MB

给镜像打标签

[root@localhost ~]# docker tag b6e6318c172b docker.io/scutbot/simlatorx
[root@localhost ~]# docker images
REPOSITORY                                  TAG            IMAGE ID       CREATED         SIZE
registry.sim.scutbot.cn/simulatorx/2023ul   beta-1.1.1.5   b6e6318c172b   2 weeks ago     940MB
scutbot/simlatorx                           latest         b6e6318c172b   2 weeks ago     940MB
minio/minio                                 latest         c5442c4190b8   2 months ago    254MB
whyour/qinglong                             2.10.13        5997b3824cbe   15 months ago   434MB
centos                                      latest         5d0da3dc9764   19 months ago   231MB
[root@localhost ~]# docker tag b6e6318c172b docker.io/scutbot/simlatorx:v1.0.1
[root@localhost ~]# docker images
REPOSITORY                                  TAG            IMAGE ID       CREATED         SIZE
scutbot/simlatorx                           latest         b6e6318c172b   2 weeks ago     940MB
scutbot/simlatorx                           v1.0.1         b6e6318c172b   2 weeks ago     940MB
registry.sim.scutbot.cn/simulatorx/2023ul   beta-1.1.1.5   b6e6318c172b   2 weeks ago     940MB
minio/minio                                 latest         c5442c4190b8   2 months ago    254MB
whyour/qinglong                             2.10.13        5997b3824cbe   15 months ago   434MB
centos                                      latest         5d0da3dc9764   19 months ago   231MB

删除镜像

[root@localhost ~]# docker images | grep scutbot
scutbot/simlatorx                           latest         b6e6318c172b   2 weeks ago     940MB
scutbot/simlatorx                           v1.0.1         b6e6318c172b   2 weeks ago     940MB
registry.sim.scutbot.cn/simulatorx/2023ul   beta-1.1.1.5   b6e6318c172b   2 weeks ago     940MB
//删除对应为lasest标签的镜像
[root@localhost ~]# docker rmi scutbot/simlatorx:latest
Untagged: scutbot/simlatorx:latest
[root@localhost ~]# docker images | grep scutbot
scutbot/simlatorx                           v1.0.1         b6e6318c172b   2 weeks ago     940MB
registry.sim.scutbot.cn/simulatorx/2023ul   beta-1.1.1.5   b6e6318c172b   2 weeks ago     940MB
//删除同样imagesID的镜像
[root@localhost /]# docker rmi -f 300e315adb2f
Untagged: itying/centos:v1.0.1
Untagged: centos:8.3.2011

本地镜像推送

[root@localhost ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to <https://hub.docker.com> to create one.
Username: dreamini
Password: *******
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
<https://docs.docker.com/engine/reference/commandline/login/#credentials-store>

Login Succeeded
[root@localhost ~]# cat .docker/config.json
{
    "auths": {
        "<https://index.docker.io/v1/>": {
            "auth": "ZHJlYW1pbmk6dipjMlVtaTYmLXRCTEIy"
        }
    }
}

推送本地镜像到远程

[root@localhost ~]# docker tag 9ed4aefc74f6 docker.io/dreamini/alpine:v1.01
[root@localhost ~]# docker push docker.io/dreamini/alpine:v1.01
The push refers to repository [docker.io/dreamini/alpine]
f1417ff83b31: Pushed
v1.01: digest: sha256:b6ca290b6b4cdcca5b3db3ffa338ee0285c11744b4a6abaa9627746ee3291d8d size: 528
[root@localhost ~]#

如果遇到*denied: requested access to the resource is denied* ,意思是没有权限,请将标签打为docker.io/本人用户名/***

查看容器操作日志