Docker Registry 建立私有仓库

2019-01-28  本文已影响0人  大猪小猪在菜盘

修改镜像存放路径:

{
  "insecure-registries": [
    "172.22.122.21:5000"
  ],
  "data-root": "/yourpath/docker-images",
  "registry-mirrors": ["https://registry.docker-cn.com"]
}              

1.下载Registry

docker pull registry 

2. 运行Registry

docker run -d -p 5000:5000 registry 

Docker重启之后不会自动重启registry,需要手动重启

docker start registry

3. 建立本地镜像并上传

docker tag 504332db8051 172.22.122.21:5000/rabbitmq-3.7-management
docker push 172.22.122.21:5000/rabbitmq-3.7-management

可能出出现如下错误

Error response from daemon: Get https://172.22.122.21:5000/v1/_ping: http: server gave HTTP response to HTTPS client

因为默认采用https传输,我们需要修改下配置,修改/etc/docker/daemon.json

{
    "insecure-registries": [
        "172.22.122.21:5000"
    ],
    "registry-mirrors": [
        "http://172.22.122.21:5000"
    ]
}

重启docker然后测试能否push成功,可以敲入如下的url查看:

[root@yyy ~] curl 172.22.122.21:5000/v2/_catalog
{"repositories":["rabbitmq-3.7-management"]}

如果有返回,则说明push成功了

4.别的机器拉取镜像

在内网的不同机器上执行以下命令即可拉取:

docker pull 172.22.122.21:5000/rabbitmq-3.7-management
上一篇下一篇

猜你喜欢

热点阅读