docker仓库

Posted shamo89

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker仓库相关的知识,希望对你有一定的参考价值。

docker公共仓库

https://hub.docker.com/

国内docker仓库

阿里 开发者平台

镜像中心 - 网易蜂巢

https://hub.tenxcloud.com/

docker仓库

docker仓库是存放镜像的地方,分为共有仓库和私有仓库。

搭建docker本地私有仓库

  • 使用registry镜像创建私有仓库
    • docker run -d -p 5000:5000 registry
      • 支持的参数:-v:指定registry镜像存放的本地位置,默认是存放到容器、temp/registry目录下
      • docker run -d -p 5000:5000 -v /usr/local/docker/images/registry  registry
    • 以上命令,自动下载并创建registry容器,并创建私有仓库,监听端口为5000
  • 上传镜像到私有仓库
    • 将镜像命名为: ip:端口号/镜像名称。 例如:docker tag redis 127.0.0.1:5000/myredis
    • docker push 127.0.0.1:5000/myredis
  • 查看私有仓库的镜像
    • 查看私有仓库的镜像: curl -XGET http://127.0.0.1:5000/v2/_catalog
    • 获取某个镜像的标签列表: curl -XGET http://127.0.0.1:5000/v2/myredis/tags/list
  • 从私有仓库下载镜像
    • docker pull ip:端口号/镜像名称
技术分享图片
[[email protected] ~]# docker run -d -p 5000:5000 registry
Unable to find image ‘registry:latest‘ locally
latest: Pulling from library/registry
81033e7c1d6a: Pull complete
b235084c2315: Pull complete
c692f3a6894b: Pull complete
ba2177f3a70e: Pull complete
a8d793620947: Pull complete
Digest: sha256:672d519d7fd7bbc7a448d17956ebeefe225d5eb27509d8dc5ce67ecb4a0bce54
Status: Downloaded newer image for registry:latest
1cd1bd60f83eb8d7ddd05ab5b7eac2842a993b88f8d5e344915f619ca36c65df
[[email protected] ~]# docker images
REPOSITORY                                          TAG                 IMAGE ID            CREATED             SIZE
myimprt                                             1.0.0               1debb407c788        17 hours ago        31.5MB
myredis                                             latest              0bdd49822deb        3 weeks ago         32.6MB
registry.cn-zhangjiakou.aliyuncs.com/cytong/redis   latest              0bdd49822deb        3 weeks ago         32.6MB
registry                                            latest              d1fd7d86a825        2 months ago        33.3MB
[[email protected] ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                    NAMES
1cd1bd60f83e        registry            "/entrypoint.sh /etc…"   About a minute ago   Up About a minute   0.0.0.0:5000->5000/tcp   thirsty_kirch
87ae8e633e1b        myredis             "docker-entrypoint.s…"   17 hours ago         Up 17 hours         6379/tcp                 kind_wright
[[email protected] ~]# docker tag myredis 127.0.0.1:5000/myredis
[[email protected] ~]# docker images
REPOSITORY                                          TAG                 IMAGE ID            CREATED             SIZE
myimprt                                             1.0.0               1debb407c788        17 hours ago        31.5MB
127.0.0.1:5000/myredis                              latest              0bdd49822deb        3 weeks ago         32.6MB
myredis                                             latest              0bdd49822deb        3 weeks ago         32.6MB
registry.cn-zhangjiakou.aliyuncs.com/cytong/redis   latest              0bdd49822deb        3 weeks ago         32.6MB
registry                                            latest              d1fd7d86a825        2 months ago        33.3MB
[[email protected] ~]# docker push 127.0.0.1:5000/myredis
The push refers to repository [127.0.0.1:5000/myredis]
0b4e383175e3: Pushed
fe632b435885: Pushed
833391bcaae3: Pushed
968231311ad9: Pushed
76dabc6d8ad2: Pushed
373a30c24545: Pushed
a9148f5200b0: Pushed
cdd3de0940ab: Pushed
fc56279bbb33: Pushed
b38367233d37: Pushed
2aebd096e0e2: Pushed
latest: digest: sha256:c23c35b2f5cb5cb28135a8bc375cead3b9a1dbd9593c7d7fff263a2be4f2ba82 size: 2613
[[email protected] ~]# curl -XGET http://127.0.0.1:5000/v2/_catalog
{"repositories":["myredis"]}
[[email protected] ~]# curl -XGET http://127.0.0.1:5000/v2/myredis/tags/list
{"name":"myredis","tags":["latest"]}
[[email protected] ~]# docker images
REPOSITORY                                          TAG                 IMAGE ID            CREATED             SIZE
myimprt                                             1.0.0               1debb407c788        18 hours ago        31.5MB
registry.cn-zhangjiakou.aliyuncs.com/cytong/redis   latest              0bdd49822deb        3 weeks ago         32.6MB
127.0.0.1:5000/myredis                              latest              0bdd49822deb        3 weeks ago         32.6MB
myredis                                             latest              0bdd49822deb        3 weeks ago         32.6MB
registry                                            latest              d1fd7d86a825        2 months ago        33.3MB
[[email protected] ~]# docker rmi 127.0.0.1:5000/myredis
Untagged: 127.0.0.1:5000/myredis:latest
Untagged: 127.0.0.1:5000/[email protected]:c23c35b2f5cb5cb28135a8bc375cead3b9a1dbd9593c7d7fff263a2be4f2ba82
[[email protected] ~]# docker images
REPOSITORY                                          TAG                 IMAGE ID            CREATED             SIZE
myimprt                                             1.0.0               1debb407c788        18 hours ago        31.5MB
myredis                                             latest              0bdd49822deb        3 weeks ago         32.6MB
registry.cn-zhangjiakou.aliyuncs.com/cytong/redis   latest              0bdd49822deb        3 weeks ago         32.6MB
registry                                            latest              d1fd7d86a825        2 months ago        33.3MB
[[email protected] ~]# curl -X GET http://localhost:5000/v2/_catalog
{"repositories":["myredis"]}
[[email protected] ~]# docker pull 127.0.0.1:5000/myredis
Using default tag: latest
latest: Pulling from myredis
Digest: sha256:c23c35b2f5cb5cb28135a8bc375cead3b9a1dbd9593c7d7fff263a2be4f2ba82
Status: Downloaded newer image for 127.0.0.1:5000/myredis:latest
[[email protected] ~]# docker images
REPOSITORY                                          TAG                 IMAGE ID            CREATED             SIZE
myimprt                                             1.0.0               1debb407c788        18 hours ago        31.5MB
127.0.0.1:5000/myredis                              latest              0bdd49822deb        3 weeks ago         32.6MB
myredis                                             latest              0bdd49822deb        3 weeks ago         32.6MB
registry.cn-zhangjiakou.aliyuncs.com/cytong/redis   latest              0bdd49822deb        3 weeks ago         32.6MB
registry                                            latest              d1fd7d86a825        2 months ago        33.3MB
技术分享图片

 


以上是关于docker仓库的主要内容,如果未能解决你的问题,请参考以下文章

docker--docker仓库

gitlab私人代码仓库搭建(docker)

Docker企业级私有仓库

百余 Docker 注册表配置出错,数千代码仓库遭暴露

Docker私有仓库Registry的搭建验证

docker学习11-上传本地镜像到镜像仓库