17-docker 私有仓库

1.安装运行 docker-registry

[root@docker03 ~]# docker run -itd -p 5000:5000 --restart=always --name registry -v /opt:/opt 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
065ef69a036860106d1807d94fcf8aeb7a2e0258dc47a6100d269d3aff28c6e7

 2.在私有仓库上传、搜索、下载镜像

# 镜像打tag
[root@docker03 ~]# docker tag centos 192.168.1.26:5000/centos

# 查看打好tag的镜像192.168.1.26:5000/centos 
[root@docker03 ~]# docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
sunmmi/nginx               latest              1fd61459671b        23 hours ago        385MB
192.168.1.26:5000/centos   latest              2d194b392dd1        2 weeks ago         195MB
centos                     latest              2d194b392dd1        2 weeks ago         195MB
registry                   latest              d1fd7d86a825        2 months ago        33.3MB
alpine                     latest              3fd9065eaf02        2 months ago        4.14MB
hello-world                latest              f2a91732366c        4 months ago        1.85kB

# 推送镜像到私有仓库,显示不能用http
[root@docker03 ~]# docker push 192.168.1.26:5000/centos
The push refers to repository [192.168.1.26:5000/centos]
Get https://192.168.1.26:5000/v2/: http: server gave HTTP response to HTTPS client

# 报错解决,编辑daemon.json,增加insecure-registries,重启服务
[root@docker03 ~]# vim /etc/docker/daemon.json 

{
  "registry-mirrors": ["https://de378wx8.mirror.aliyuncs.com"],
  "insecure-registries": ["192.168.1.26:5000"],
  "bip": "10.10.10.1/24",
  "dns": ["223.5.5.5","223.6.6.6"]
}
[root@docker03 ~]# systemctl restart docker

# 重新推送成功
[root@docker03 ~]# docker push 192.168.1.26:5000/centos
The push refers to repository [192.168.1.26:5000/centos]
b03095563b79: Pushed 
latest: digest: sha256:8c7ac054adab3692f7026d49fd1c4df69aa6a138b2f076b432d2ac0164c022d3 size: 529

# 用 curl 查看仓库中的镜像
[root@docker03 ~]# curl 192.168.1.26:5000/v2/_catalog
{"repositories":["centos"]}

 

posted @ 2018-03-22 09:29  sunmmi  阅读(217)  评论(0)    收藏  举报