---
title: "docker仓库使用简介"
author: "dbp_cn"
date: "2018-02-01T11:42:05Z"
tags: []
categories: ["操作系统"]
slug: "docker"
draft: false
lastmod: "2018-07-02T17:13:21Z"
id: 2409942
url: "https://dbp5588.iteye.com/blog/2409942"
---

1.docker 登陆后 push镜像到docker hub 中遇到unauthorized authentication required问题，

镜像分公有和私有，你pull的镜像是公有镜像，由docker hub来维护，那个地址对你来说只能做pull操作，不能做push操作，所以会提示没有权限。

你要push到你自己的镜像库中去。先要用tag修改下镜像的名字，也就是docker tag hello-world your\_namespace/hello-world  
docker push your\_namespace/hello-world.

比如我的hub的repo名为billdan, 并新新建了一个hello-world镜像则需要如下操作：

docker tag hello-world billdan/hello-world

docker push billdan/hello-world

2.新建自己的仓库：

sudo docker run -d -p 5000:5000 -v /apps/myRegistry:/tmp/registry --name localRegistry registry

推送本地镜像：

    1) 给镜像重置repository: sudo docker tag docker.io/alpine 172.31.50.39:5000/alpine

     2) 上传镜像：sudo docker push 172.31.50.39:5000/alpine

 

3\. 查询私有仓库包含哪些镜像：

```
VirtualBox:~$ curl -X GET http://172.31.50.39:5000/v2/_catalog
{"repositories":["alpine","redis"]}
```

 从上面命令可以看到仓库含有两个镜像：alpine 和redis

查询某一镜像包含哪些tag：

```
VirtualBox:~$ curl -X GET http://172.31.50.39:5000/v2/redis/tags/list
{"name":"redis","tags":["alpine"]}
```

 本例查询镜像redis的tag