Docker学习(六)image仓库

作者: 我犟不过你 | 来源:发表于2020-09-25 10:06 被阅读0次

类似于maven,或者github,可以将我们的镜像推送到服务器docker hub中,供别人使用,前提是要登录到docker hub。

1、创建docker hub账号

进入https://hub.docker.com/

hub.docker.com

按照上图注册自己的账号,并登录(sign in)

sign in

登陆成功

登陆成功

2、上传我们的镜像到docker hub

通过docker login 命令登录docker hub

[root@iZ2ze7sn66bchxncut8rgsZ opt]# 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: 18351001571
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

查看下当前images:

[root@iZ2ze7sn66bchxncut8rgsZ opt]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
redis               latest              84c5f6e03bf0        13 days ago         104MB
nginx               latest              7e4d58f0e5f3        13 days ago         133MB
centos              7                   7e6257c9f8d8        6 weeks ago         203MB
hello-world         latest              bf756fb1ae65        8 months ago        13.3kB

上传hello-world到docker hub

[root@iZ2ze7sn66bchxncut8rgsZ opt]# docker push hello-world
The push refers to repository [docker.io/library/hello-world]
9c27e219663c: Layer already exists 
errors:
denied: requested access to the resource is denied
unauthorized: authentication required

推送失败了,名称与docker hub重复了,改个名字

[root@iZ2ze7sn66bchxncut8rgsZ opt]# docker tag hello-world wrx-hello-world
[root@iZ2ze7sn66bchxncut8rgsZ opt]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
redis               latest              84c5f6e03bf0        13 days ago         104MB
nginx               latest              7e4d58f0e5f3        13 days ago         133MB
centos              7                   7e6257c9f8d8        6 weeks ago         203MB
hello-world         latest              bf756fb1ae65        8 months ago        13.3kB
wrx-hello-world     latest              bf756fb1ae65        8 months ago        13.3kB

上传wrx-hello-world:

[root@iZ2ze7sn66bchxncut8rgsZ opt]# docker push wrx-hello-world
The push refers to repository [docker.io/library/wrx-hello-world]
9c27e219663c: Preparing 
denied: requested access to the resource is denied

仍然失败了,需要在我们上传的镜像前加上自己的账号,修改名称:

[root@iZ2ze7sn66bchxncut8rgsZ opt]# docker tag wrx-hello-world 18351001571/wrx-hello-world

再次上传:

[root@iZ2ze7sn66bchxncut8rgsZ opt]# docker push 18351001571/wrx-hello-world
The push refers to repository [docker.io/18351001571/wrx-hello-world]
9c27e219663c: Mounted from library/hello-world 
latest: digest: sha256:90659bf80b44ce6be8234e6ff90a1ac34acbeb826903b02cfa0da11c82cbc042 size: 525

上传成功,去docker hub看一下:

docker hub

删除本地镜像,重新pull,看是否能成功

[root@iZ2ze7sn66bchxncut8rgsZ ~]# docker rmi 18351001571/wrx-hello-world:latest 
Untagged: 18351001571/wrx-hello-world:latest
Untagged: 18351001571/wrx-hello-world@sha256:90659bf80b44ce6be8234e6ff90a1ac34acbeb826903b02cfa0da11c82cbc042
Deleted: sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b
Deleted: sha256:9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63
[root@iZ2ze7sn66bchxncut8rgsZ ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
redis               latest              84c5f6e03bf0        2 weeks ago         104MB
nginx               latest              7e4d58f0e5f3        2 weeks ago         133MB
centos              7                   7e6257c9f8d8        6 weeks ago         203MB
[root@iZ2ze7sn66bchxncut8rgsZ ~]# docker pull 18351001571/wrx-hello-world:latest
latest: Pulling from 18351001571/wrx-hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:90659bf80b44ce6be8234e6ff90a1ac34acbeb826903b02cfa0da11c82cbc042
Status: Downloaded newer image for 18351001571/wrx-hello-world:latest
[root@iZ2ze7sn66bchxncut8rgsZ ~]# docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
redis                         latest              84c5f6e03bf0        2 weeks ago         104MB
nginx                         latest              7e4d58f0e5f3        2 weeks ago         133MB
centos                        7                   7e6257c9f8d8        6 weeks ago         203MB
18351001571/wrx-hello-world   latest              bf756fb1ae65        8 months ago        13.3kB

相关文章

  • Docker学习(六)image仓库

    类似于maven,或者github,可以将我们的镜像推送到服务器docker hub中,供别人使用,前提是要登录到...

  • docker草稿

    基本组成 Docker Image 镜像 Docker Container容器 Docker Registry仓库...

  • Docker的三个基本概念(镜像、容器,仓库)

    镜像(image)容器(Container)仓库(repository) docker镜像: Docker 镜像,...

  • docker常用命令

    IMAGE ID镜像IDREPOSITY 仓库TAG标签docker search [NAME]docker in...

  • Docker常用命令

    Docker包括镜像(image)、容器(container)和仓库(repository) Docker安装与启...

  • Docker 基本内容

    学习Docker, 需要理解下列三个基本概念。• 镜像(Image)• 容器(Container)• 仓库(Rep...

  • docker的镜像常规操作

    docker pull [image]:[tag] 解释:从远程仓库获取镜像的命令。例如:docker pull ...

  • Docker-基础指令

    Docker docker文档地址: 基本的名词 客户端,服务器,仓库 镜像(image): docker镜像就好...

  • Docke第一次使用介绍

    Docker Docker的三大核心概念:镜像、容器、仓库 首先我们来看下镜像。 Docker image 查看当...

  • Docker核心要素

    Docker包括三个核心要素:镜像(Image)容器(Container)仓库(Repository)Docker...

网友评论

    本文标题:Docker学习(六)image仓库

    本文链接:https://www.haomeiwen.com/subject/elnzyktx.html