环境
- OS: Ubuntu16.04 X86_64
查询registery
$ docker search registry
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
registry The Docker Registry 2.0 implementation for... 2196 [OK]
konradkleine/docker-registry-frontend Browse and modify your Docker registry in ... 200 [OK]
...
上述第一个即为所需要的私人仓库的镜像。
下载镜像
$ docker pull registry
Using default tag: latest
latest: Pulling from library/registry
d6a5679aa3cf: Pull complete
...
bcd4a541795b: Pull complete
Digest: sha256:5a156ff125e5a12ac7fdec2b90b7e2ae5120fa249cf62248337b6d04abc574c8
Status: Downloaded newer image for registry:latest
启动镜像
$docker run -d -v /home/ly/docker_registry/:/var/lib/registry/ -p 5000:5000 --name myregistry registry
#-v挂载文件,-p映射端口
测试
- 1, 使用curl测试是否启动成功
$ curl -i http://localhost:5000
HTTP/1.1 200 OK
Cache-Control: no-cache
Date: Sun, 16 Sep 2018 10:58:25 GMT
Content-Length: 0
Content-Type: text/plain; charset=utf-8
- 提交一个image并且拉下了
$ docker tag hello-world localhost:5000/myhelloworld
$ docker push localhost:5000/myhelloworld
The push refers to a repository [localhost:5000/myhelloworld]
428c97da766c: Pushed
latest: digest: sha256:70f2bd...4de5 size: 524
---
$ docker pull localhost:5000/myhelloworld
Using default tag: latest
latest: Pulling from myhelloworld
Digest: sha256:70f2bd44b1c349fb6f6fbdfdfc965b1c014f901e72461a95284b48ac29334de5
Status: Image is up to date for localhost:5000/myhelloworld:latest
!!注意!! 在提交images之后,使用search命令来查看的话出现问题,log显示跟register版本有关,有相关bug:https://github.com/docker/distribution/issues/206