viernes, diciembre 16, 2016

DOCKER: Crear un registro privado en RHEL 7


Primero habilitamos el repositorio adecuado e instalamos el paquete de docker-registry que en RHEL se llama docker-distribution:


[root@forcarei registry]#  subscription-manager repos --enable=rhel-7-server-extras-rpms
[root@forcarei registry]# yum install docker-distribution

A continuación adaptamos la configuración a nuestro gusto, en este caso hemos creado un directorio para el repositorio de las imágenes:

[root@forcarei ~]$ cat /etc/docker-distribution/registry/config.yml
version: 0.1
log:
  fields:
    service: registry
storage:
    cache:
        layerinfo: inmemory
    filesystem:
        rootdirectory: /repos
http:
    addr: :5000

Arrancamos el servidor de registro:


[root@forcarei registry]# systemctl enable docker-distribution      
[root@forcarei registry]# systemctl start docker-distribution  

Probamos a hacer un PUSH contra el nuevo repositorio desde un servidor remoto:



[root@progreso ~]# docker images
REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE
registry.access.redhat.com/rhel7.2   latest              98a88a8b722a        2 weeks ago         201.4 MB

[root@progreso ~]# docker tag registry.access.redhat.com/rhel7.2 forcarei:5000/rhel7.2

[root@progreso ~]# docker images
REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE
forcarei:5000/rhel7.2                latest              98a88a8b722a        2 weeks ago         201.4 MB
registry.access.redhat.com/rhel7.2   latest              98a88a8b722a        2 weeks ago         201.4 MB

[root@progreso ~]# docker push forcarei:5000/rhel7.2
The push refers to a repository [forcarei:5000/rhel7.2]
unable to ping registry endpoint https://forcarei:5000/v0/
v2 ping attempt failed with error: Get https://forcarei:5000/v2/: http: server gave HTTP response to HTTPS client
 v1 ping attempt failed with error: Get https://forcarei:5000/v1/_ping: http: server gave HTTP response to HTTPS client

Tenemos que reconfigurar Docker para añadir el nuevo registro como inseguro:


[root@progreso ~]# cat /etc/sysconfig/docker
# /etc/sysconfig/docker

....
....

ADD_REGISTRY='--add-registry registry.access.redhat.com --add-registry forcarei:5000'

....
....

INSECURE_REGISTRY='--insecure-registry forcarei:5000'

Y listo, ya tenemos nuestro servidor docker registry local, para consultarlo podéis utilizar la herramienta drinfo.py

No hay comentarios: