Docker(五)建立私有仓库

随着创建的镜像日益增多,就需要一个保存镜像的地方,这就是仓库。

仓库目前有两张:

1:公有仓库

2:私有仓库

私有仓库建立

[root@xyue ~] docker pull registry
Using default tag: latest
latest: Pulling from library/registry
4064ffdc82fe: Pull complete 
c12c92d1c5a2: Pull complete 
4fbc9b6835cc: Pull complete 
765973b0f65f: Pull complete 
3968771a7c3a: Pull complete 
Digest: sha256:51bb55f23ef7e25ac9b8313b139a8dd45baa832943c8ad8f7da2ddad6355b3c8
Status: Downloaded newer image for registry:latest

之后需要在/etc/docker/目录底下创建json文件,否则就会报错

[root@xyue ~] vim /etc/docker/daemon.json
{"insecure-registries":["192.168.179.152:5000"]}

重启服务:上传时候回报错

[root@xyue ~]# systemctl restart docker.service

本地启动的私有仓库监听地址为5000

docker create -it registry /bin/bash
docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
6f7497fcc8c2        registry            "/entrypoint.sh /b..."   59 seconds ago      Exited (2) 20 seconds ago                       musing_turing
docker start 6f7497fcc8c2
//宿主机的/data/registry自动创建挂载容器中的/tmp/registry
docker run -d -p 5000:5000 -v /data/registry:/tmp/registry registry

//更改标记为192.168.179.152:5000/cobbler
docker tag jasonlix/docker-cobbler 192.168.175.145:5000/cobbler

//上传
docker push 192.168.179.152:5000/cobbler
--------显示---------------------
The push refers to a repository [192.168.179.1525000/cobbler]
983c23e6d629: Pushed 
58c8b3d7f322: Pushed 
e6bf41084b0e: Pushed 
eb048cf06c75: Pushed 
34e7b85d83e4: Pushed 
latest: digest: sha256:dfb7b852c32b24b92fc3dff6f559dbf3ab77cbdf1b0247a843ffcddd336f3ab0 size: 1362

//获取私有仓库列表

curl -XGET http://192.168.179.152:5000/v2/_catalog
{"repositories":["cobbler"]}