查找registry 镜像

meiya@meiya:/etc/docker$ clear
meiya@meiya:/etc/docker$ docker search registry
NAME                                    DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
registry                                The Docker Registry 2.0 implementation for s…   2552                [OK]                
konradkleine/docker-registry-frontend   Browse and modify your Docker registry in a …   222                                     [OK]
hyper/docker-registry-web               Web UI, authentication service and event rec…   166                                     [OK]
atcol/docker-registry-ui                A web UI for easy private/local Docker Regis…   114                                     [OK]
distribution/registry                   WARNING: NOT the registry official image!!! …   57                                      [OK]
jhipster/jhipster-registry              JHipster Registry, based on Netflix Eureka a…   44                                      [OK]
marvambass/nginx-registry-proxy         Docker Registry Reverse Proxy with Basic Aut…   44                                      [OK]
google/docker-registry                  Docker Registry w/ Google Cloud Storage driv…   38                                      
confluentinc/cp-schema-registry         Official Confluent Docker Images for Schema …   34                                      
joxit/docker-registry-ui                Docker registry v2 web User Interface           25                                      [OK]
klausmeyer/docker-registry-browser      Web Interface for the Docker Registry HTTP A…   19                                      [OK]
openshift/origin-docker-registry        The integrated OpenShift V3 registry            13                                      
deis/registry                           Docker image registry for the Deis open sour…   12                                      
quiq/docker-registry-ui                 Docker Registry UI                              7                                       
landoop/schema-registry-ui              UI for Confluent's Schema Registry              7                                       [OK]
parabuzzle/docker-registry-ui           Docker registry frontend for registry v2        6                                       
anoxis/registry-cli                     You can list and delete tags from your priva…   6                                       [OK]
elasticio/docker-registry-ecs           Docker image to run Docker private registry …   4                                       [OK]
allingeek/registry                      A specialization of registry:2 configured fo…   4                                       [OK]
yammer/docker-registry-cache            Simple docker registry cache using squid-pro…   1                                       [OK]
webhippie/registry                      Docker images for Docker Registry               1                                       [OK]
aibaars/docker-registry2-gcs            Docker Registry2 w/ Google Cloud Storage dri…   1                                       
convox/registry                                                                         0                                       
lorieri/registry-ceph                   Ceph Rados Gateway (and any other S3 compati…   0                                       
torchbox/kube-registry-proxy            kube-registry-proxy fork with correct timeou…   0                                       [OK]

拉取registry镜像

meiya@meiya:/etc/docker$ docker pull registry
Using default tag: latest
latest: Pulling from library/registry
c87736221ed0: Pull complete 
1cc8e0bb44df: Pull complete 
54d33bcb37f5: Pull complete 
e8afc091c171: Pull complete 
b4541f6d3db6: Pull complete 
Digest: sha256:3b00e5438ebd8835bcfa7bf5246445a6b57b9a50473e89c02ecc8e575be3ebb5
Status: Downloaded newer image for registry:latest

查看镜像

meiya@meiya:/etc/docker$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
registry            latest              f32a97de94e1        2 months ago        25.8MB

docker 镜像删除后会把所有的数据和文件都删除,所以要把宿主机的本地目录挂载到registry容器内部的目录上,在删除registry容器后依旧能保证文件和数据不丢失

meiya@meiya:/etc/docker$ mkdir -p ~/docker/data/registry
meiya@meiya:/etc/docker$ cd /
bin/        cdrom/      etc/        lib/        lost+found/ mnt/        proc/       run/        snap/       sys/        usr/        
boot/       dev/        home/       lib64/      media/      opt/        root/       sbin/       srv/        tmp/        var/        
meiya@meiya:/etc/docker$ cd /
bin/        cdrom/      etc/        lib/        lost+found/ mnt/        proc/       run/        snap/       sys/        usr/        
boot/       dev/        home/       lib64/      media/      opt/        root/       sbin/       srv/        tmp/        var/        
meiya@meiya:/etc/docker$ cd ~/docker/data/registry/
meiya@meiya:~/docker/data/registry$ pwd
/home/meiya/docker/data/registry
meiya@meiya:~/docker/data/registry$ 

创建registry镜像容器,绑定5000端口

meiya@meiya:~/docker/data/registry$ docker run -d -p 5000:5000 -v /home/meiya/docker/data/registry:/tmp/registry registry
0a922d940f7c9d7c4c3e4d81caaf3d5582e34fbb49e2824675b4c43b652e3240
meiya@meiya:~/docker/data/registry$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
0a922d940f7c        registry            "/entrypoint.sh /etc…"   7 seconds ago       Up 6 seconds        0.0.0.0:5000->5000/tcp   nifty_ganguly
meiya@meiya:~/docker/data/registry$ netstat -ntlp | grep 5000
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::5000                 :::*                    LISTEN      -                   
meiya@meiya:~/docker/data/registry$ telnet 192.168.1.57 5000
Trying 192.168.1.57...
Connected to 192.168.1.57.
Escape character is '^]'.
q
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Connection: close

400 Bad RequestConnection closed by foreign host.
meiya@meiya:~/docker/data/registry$ 

 

将本地的镜像加上tag , 然后上传私服

meiya@meiya:~/docker/data/registry$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              latest              27600aa3d7f1        37 hours ago        463MB
registry            latest              f32a97de94e1        2 months ago        25.8MB
meiya@meiya:~/docker/data/registry$ docker tag tomcat 192.168.1.57:5000/tomcat
meiya@meiya:~/docker/data/registry$ docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
192.168.1.57:5000/tomcat   latest              27600aa3d7f1        37 hours ago        463MB
tomcat                     latest              27600aa3d7f1        37 hours ago        463MB
registry                   latest              f32a97de94e1        2 months ago        25.8MB
meiya@meiya:~/docker/data/registry$ docker push 192.168.1.57:5000/tomcat
The push refers to repository [192.168.1.57:5000/tomcat]
Get https://192.168.1.57:5000/v2/: http: server gave HTTP response to HTTPS client
meiya@meiya:~/docker/data/registry$ 

这里出了个问题  ,主要是因为docker新版本默认不支持https协议,开放https协议

Get https://192.168.1.57:5000/v2/: http: server gave HTTP response to HTTPS client

解决办法,修改docker的配置文件,

修改默认的配置文件

sudo vi /etc/default/docker

加入 

DOCKER_OPTS="--registry-mirror=https://registry.docker-cn.com --insecure-registry=192.168.1.57:5000"
# Docker Upstart and SysVinit configuration file
  
#
# THIS FILE DOES NOT APPLY TO SYSTEMD
#
#   Please see the documentation for "systemd drop-ins":
#   https://docs.docker.com/engine/admin/systemd/
#

# Customize location of Docker binary (especially for development testing).
#DOCKERD="/usr/local/bin/dockerd"

# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"

DOCKER_OPTS="--registry-mirror=https://registry.docker-cn.com --insecure-registry=192.168.1.57:5000"

# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"

# This is also a handy place to tweak where Docker's temporary files go.
#export DOCKER_TMPDIR="/mnt/bigdrive/docker-tmp"

重启docker服务, 重启registry容器,重新push本地镜像

meiya@meiya:~/docker/data/registry$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
meiya@meiya:~/docker/data/registry$ docker run -d -p 5000:5000 -v /home/meiya/docker/data/registry:/tmp/registry registry
5b48b4c0147ceb6b7fec52943cd38420ac61ae488089326ff5b956b7c566f69e
meiya@meiya:~/docker/data/registry$ docker push 192.168.1.57:5000/tomcat
The push refers to repository [192.168.1.57:5000/tomcat]
d0830810b081: Pushed
32cddd6bb4cf: Pushed
f0e1731fd286: Pushed
2b6c38ff3137: Pushed
d38f3d5a39fb: Pushed
fe60061c6c4e: Pushed
7d63f8777ebf: Pushed
1b958b53b256: Pushed
2c719774c1e1: Pushed
ec62f19bb3aa: Pushed
f94641f1fe1f: Pushed
latest: digest: sha256:b3e89c95260685b18b31acb078b168c30a3b94ba561801bf374ccec0e7c622c6 size: 2626

 

ps:

第二种办法是修改  /etc/docker/daemon.json 文件,重启docker服务, 重启registry容器,重新push本地镜像

meiya@meiya:~/docker/data/registry$ cat /etc/docker/daemon.json 
{
    "registry-mirrors": ["https://hdokp13m.mirror.aliyuncs.com"],
    "insecure-registries":["192.168.1.57:5000"],
    "registry-mirrors": ["https://registry.docker-cn.com"]
}

 

查看私有仓库中的镜像

meiya@meiya:~/docker/data/registry$ curl get http://192.168.1.57:5000/v2/_catalog
curl: (6) Could not resolve host: get
{"repositories":["tomcat"]}

 ps:

  部分旧的docker版本使用的地址是 http://192.168.1.57:5000/v2/_search

从私有仓库下载镜像

meiya@meiya:~/docker/data/registry$ docker pull 192.168.1.57:5000/tomcat
Using default tag: latest
latest: Pulling from tomcat
Digest: sha256:b3e89c95260685b18b31acb078b168c30a3b94ba561801bf374ccec0e7c622c6
Status: Image is up to date for 192.168.1.57:5000/tomcat:latest

 

posted on 2019-05-10 11:25  肖建锋  阅读(2697)  评论(0编辑  收藏  举报