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:端口号/镜像名称
[root@localhost ~]# 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
[root@localhost ~]# 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
[root@localhost ~]# 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
[root@localhost ~]# docker tag myredis 127.0.0.1:5000/myredis
[root@localhost ~]# 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
[root@localhost ~]# 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
[root@localhost ~]# curl -XGET http://127.0.0.1:5000/v2/_catalog
{"repositories":["myredis"]}
[root@localhost ~]# curl -XGET http://127.0.0.1:5000/v2/myredis/tags/list
{"name":"myredis","tags":["latest"]}
[root@localhost ~]# 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
[root@localhost ~]# docker rmi 127.0.0.1:5000/myredis
Untagged: 127.0.0.1:5000/myredis:latest
Untagged: 127.0.0.1:5000/myredis@sha256:c23c35b2f5cb5cb28135a8bc375cead3b9a1dbd9593c7d7fff263a2be4f2ba82
[root@localhost ~]# 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
[root@localhost ~]# curl -X GET http://localhost:5000/v2/_catalog
{"repositories":["myredis"]}
[root@localhost ~]# 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
[root@localhost ~]# 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
原文地址:https://www.cnblogs.com/zhuhaichan/p/8663838.html