天天看点

运行自己的docker registry

           运行自己的docker registry

1.从容器运行registry

docker run -d -p 5000:5000 registry

[root@localhost ~]# docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMES

2c4d1944b536        registry:latest     "docker-registry"   13 seconds ago      Up 10 seconds       0.0.0.0:5000->5000/tcp   mad_leakey          

2.测试新registry

3.为本地的一个镜像打标签

docker tag 580949ea7897 192.168.32.16:5000/zhoufujin/apache

4.访问私有仓库

[root@localhost docker]# curl 127.0.0.1:5000/v1/search

{"num_results": 0, "query": "", "results": []} 私有仓库为空

5.修改docker配置文件定制url

/etc/sysconfig/docker

OPTIONS='--selinux-enabled --insecure-registry 192.168.32.16:5000'

6.重启docker服务

从容器运行registry

7.上传镜像

[root@localhost docker]# docker push 192.168.32.16:5000/zhoufujin/apache

The push refers to a repository [192.168.32.16:5000/zhoufujin/apache] (len: 1)

Sending image list

Pushing repository 192.168.32.16:5000/zhoufujin/apache (1 tags)

511136ea3c5a: Image successfully pushed 

5b12ef8fd570: Image successfully pushed 

a30bc9f3097e: Image successfully pushed 

e82bf4a08352: Image successfully pushed 

71de305bc72d: Image successfully pushed 

7871f0e862fd: Image successfully pushed 

254de5f17d27: Image successfully pushed 

c7b9cd7a6788: Image successfully pushed 

580949ea7897: Image successfully pushed 

Pushing tag for rev [580949ea7897] on {http://192.168.32.16:5000/v1/repositories/zhoufujin/apache/tags/latest}

查看私有仓库是否存在对应的镜像

{"num_results": 1, "query": "", "results": [{"description": "", "name": "zhoufujin/apache"}]}

8.浏览器访问仓库

192.168.32.16/v1/search

<a href="http://s3.51cto.com/wyfs02/M00/6D/78/wKioL1VlN5SybCawAACwZbFnf2M256.jpg" target="_blank"></a>

本文转自 shouhou2581314 51CTO博客,原文链接:http://blog.51cto.com/thedream/1655560,如需转载请自行联系原作者