dockerHub镜像仓库的使用

注册账号

官网:https://hub.docker.com/

登录账号

通过 docker login 命令输入账号密码登录 DockerHub

[root@centos8 dockerfile]# 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: flippedxyy
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@centos8 dockerfile]# 

推送镜像至仓库

先给镜像设置标签
再将镜像推送至仓库

docker tag local-image:tagname new-repo:tagname
docker push new-repo:tagname 

如果没有指定TAG,那么默认为latest,镜像名必须全小写

[root@centos8 dockerfile]# docker tag hello-world:latest flippedxyy/my_hello_world
[root@centos8 dockerfile]# docker tag hello-world:latest flippedxyy/my_hello_world:1.0

[root@centos8 dockerfile]# docker images
REPOSITORY                  TAG       IMAGE ID       CREATED        SIZE
flippedxyy/my_hello_world   1.0       feb5d9fea6a5   3 weeks ago    13.3kB
flippedxyy/my_hello_world   latest    feb5d9fea6a5   3 weeks ago    13.3kB
hello-world                 latest    feb5d9fea6a5   3 weeks ago    13.3kB

[root@centos8 dockerfile]# docker push flippedxyy/my_hello_world
Using default tag: latest
The push refers to repository [docker.io/flippedxyy/my_hello_world]
e07ee1baac5f: Mounted from flippedxyy/test_hello_world 
latest: digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4 size: 525
[root@centos8 dockerfile]# docker push flippedxyy/my_hello_world:1.0 
The push refers to repository [docker.io/flippedxyy/my_hello_world]
e07ee1baac5f: Layer already exists 
1.0: digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4 size: 525
[root@centos8 dockerfile]#

查看仓库

在这里插入图片描述

拉取镜像

通过 docker pull xxxx/test-hello-world 测试镜像是否可以拉取

[root@centos8 dockerfile]# docker rmi flippedxyy/my_hello_world:latest flippedxyy/my_hello_world:1.0 
Untagged: flippedxyy/my_hello_world:latest
Untagged: flippedxyy/my_hello_world:1.0
Untagged: flippedxyy/my_hello_world@sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4
[root@centos8 dockerfile]# docker pull flippedxyy/my_hello_world
Using default tag: latest
latest: Pulling from flippedxyy/my_hello_world
Digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4
Status: Downloaded newer image for flippedxyy/my_hello_world:latest
docker.io/flippedxyy/my_hello_world:latest
[root@centos8 dockerfile]# docker pull flippedxyy/my_hello_world:1.0
1.0: Pulling from flippedxyy/my_hello_world
Digest: sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4
Status: Downloaded newer image for flippedxyy/my_hello_world:1.0
docker.io/flippedxyy/my_hello_world:1.0
[root@centos8 dockerfile]# docker images
REPOSITORY                  TAG       IMAGE ID       CREATED        SIZE
flippedxyy/my_hello_world   1.0       feb5d9fea6a5   3 weeks ago    13.3kB
flippedxyy/my_hello_world   latest    feb5d9fea6a5   3 weeks ago    13.3kB
hello-world                 latest    feb5d9fea6a5   3 weeks ago    13.3kB
[root@centos8 dockerfile]# 

退出账号

docker logout

[root@centos8 dockerfile]# docker logout 
Removing login credentials for https://index.docker.io/v1/
posted @ 2021-10-18 15:51  cheems~  阅读(254)  评论(0编辑  收藏  举报