Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
Docker: Advanced 
registry usage 
September 17th, 2014 in Freiburg
Contents 
1. What’s a registry? 
2. Advanced configuration 
a. Search index 
b. Mirroring 
c. Adding a redis cache 
d. Mor...
What’s a registry? 
• Storage component for docker images 
• Open-source python app 
• docker/docker-registry on github 
•...
What’s a registry? 
• Several storage backends supported 
• Filesystem 
• Boto (S3, Google Compute, ...) 
• OpenStack Swif...
Advanced configuration 
The registry image is great for quick setup and testing, but 
we can make it even better with some...
Search index 
Enabling a basic search index is easy! 
docker run -d -p 5000:5000 -e 
SEARCH_BACKEND=sqlalchemy registry:0....
Search index 
Let’s put our SQLite database in a volume. 
docker run -d -p 5000:5000 
-e SEARCH_BACKEND=sqlalchemy 
-e SQL...
Search index 
Also, we want to keep our image store persistent across 
restarts! 
docker run -d -p 5000:5000 
-e SEARCH_BA...
Search index 
This is quite a mouthful... Let’s make a Dockerfile instead. 
$ docker build -t myregistry . 
$ docker run -...
Search index 
Don’t like SQLite? That’s fine too!
Mirroring 
Having a local copy of commonly used images can be very 
helpful!
Mirroring 
“Standard“ method: 
$ docker pull busybox:latest 
$ docker tag busybox:latest myregistry. 
com/busybox:latest 
...
Mirroring 
Better method: Enable mirroring on your registry! 
ENV MIRROR_SOURCE https://registry-1.docker.io 
ENV MIRROR_S...
Mirroring 
• On the first pull, immutable data (metadata, layers, 
image ancestry) is stored locally on the mirror. 
• The...
Adding a redis cache 
First let’s start up a redis container. 
$ docker run --name rediscache -d redis:2.8.13 
Then we’re ...
Adding a redis cache 
• Copy the config_sample.yml file where our Dockerfile 
from before is. 
• Add the following line to...
Adding a redis cache 
• Create a link with our rediscache container when 
starting up the registry 
docker run -d -p 5000:...
More configuration! 
• Use an nginx or Apache frontend to enforce basic auth. 
• You can then do: docker login my.registry...
Extending the code 
• You’ll need time and some Python proficiency. 
• But for advanced usage, it can be worth it! 
• If y...
Extending the code 
• You can implement a new storage driver by inheriting 
docker_registry.core.driver.Base 
• Leverage t...
• Code: github.com/docker/docker-registry 
• DockerHub: registry.hub.docker.com/_/registry 
• Contact me: 
• Twitter @j0ff...
Próxima SlideShare
Cargando en…5
×

Docker Advanced registry usage

7.442 visualizaciones

Publicado el

Docker Advanced registry usage by Joffrey Fuhrer at the Docker Freiburg meetup #1

Publicado en: Tecnología
  • Sé el primero en comentar

Docker Advanced registry usage

  1. 1. Docker: Advanced registry usage September 17th, 2014 in Freiburg
  2. 2. Contents 1. What’s a registry? 2. Advanced configuration a. Search index b. Mirroring c. Adding a redis cache d. More! 3. Extending the code
  3. 3. What’s a registry? • Storage component for docker images • Open-source python app • docker/docker-registry on github • Current stable version: 0.8.1 • Available as an official image docker run -d -p 5000:5000 registry:0.8.1
  4. 4. What’s a registry? • Several storage backends supported • Filesystem • Boto (S3, Google Compute, ...) • OpenStack Swift
  5. 5. Advanced configuration The registry image is great for quick setup and testing, but we can make it even better with some tinkering! • Enabling search • Mirroring another registry (even the official one!) • Adding a redis cache • And more!
  6. 6. Search index Enabling a basic search index is easy! docker run -d -p 5000:5000 -e SEARCH_BACKEND=sqlalchemy registry:0.8.1
  7. 7. Search index Let’s put our SQLite database in a volume. docker run -d -p 5000:5000 -e SEARCH_BACKEND=sqlalchemy -e SQLALCHEMY_INDEX_DATABASE=sqlite:////opt/sqlitedb/reg.db -v /opt/sqlitedb:/opt/sqlitedb registry:0.8.1
  8. 8. Search index Also, we want to keep our image store persistent across restarts! docker run -d -p 5000:5000 -e SEARCH_BACKEND=sqlalchemy -e SQLALCHEMY_INDEX_DATABASE=sqlite:////opt/sqlitedb/reg.db -e STORAGE_PATH=/opt/registry -v /opt/registry/storage:/opt/registry -v /opt/sqlitedb:/opt/sqlitedb registry:0.8.1
  9. 9. Search index This is quite a mouthful... Let’s make a Dockerfile instead. $ docker build -t myregistry . $ docker run -d -p 5000:5000 -v /opt/registry/storage:/opt/registry -v /opt/registry/index:/opt/sqlitedb myregistry That’s better!
  10. 10. Search index Don’t like SQLite? That’s fine too!
  11. 11. Mirroring Having a local copy of commonly used images can be very helpful!
  12. 12. Mirroring “Standard“ method: $ docker pull busybox:latest $ docker tag busybox:latest myregistry. com/busybox:latest $ docker push myregistry.com/busybox:latest $ docker pull busybox:buildroot-2014.02 ...
  13. 13. Mirroring Better method: Enable mirroring on your registry! ENV MIRROR_SOURCE https://registry-1.docker.io ENV MIRROR_SOURCE_INDEX https://index.docker.io
  14. 14. Mirroring • On the first pull, immutable data (metadata, layers, image ancestry) is stored locally on the mirror. • The source is always contacted to retrieve mutable data (list of tags, <tag / image ID> mappings)... • ... unless you enable the redis cache, then tag data is kept for some time. • Set MIRROR_TAGS_CACHE_TTL accordingly!
  15. 15. Adding a redis cache First let’s start up a redis container. $ docker run --name rediscache -d redis:2.8.13 Then we’re going to edit config/config_sample.yml cache: host: _env:REDISCACHE_PORT_6379_TCP_ADDR port: _env:REDISCACHE_PORT_6379_TCP_PORT db: 0 cache_lru: host: _env:REDISCACHE_PORT_6379_TCP_ADDR port: _env:REDISCACHE_PORT_6379_TCP_PORT db: 1
  16. 16. Adding a redis cache • Copy the config_sample.yml file where our Dockerfile from before is. • Add the following line to our Dockerfile: ADD ./config_sample.yml /docker-registry/ config/config_sample.yml • Create a link with our rediscache container when starting up the registry docker run -d -p 5000:5000 --link rediscache:rediscache -v /opt/registry/storage:/opt/registry -v /opt/registry/index:/opt/sqlitedb myregistry
  17. 17. Adding a redis cache • Create a link with our rediscache container when starting up the registry docker run -d -p 5000:5000 --link rediscache:rediscache -v /opt/registry/storage:/opt/registry -v /opt/registry/index:/opt/sqlitedb myregistry • All set!
  18. 18. More configuration! • Use an nginx or Apache frontend to enforce basic auth. • You can then do: docker login my.registry.com • Only works over HTTPS! • Enable e-mail notifications when an exception is encountered • See the email_notifications section of the configuration
  19. 19. Extending the code • You’ll need time and some Python proficiency. • But for advanced usage, it can be worth it! • If you make something cool, think about giving back to the community! We accept pull requests.
  20. 20. Extending the code • You can implement a new storage driver by inheriting docker_registry.core.driver.Base • Leverage the signals API in docker_registry.lib.signals • Implement a new search backend by inheriting docker_registry.lib.index.Index • Other ideas? Talk to us, let us know if we can help!
  21. 21. • Code: github.com/docker/docker-registry • DockerHub: registry.hub.docker.com/_/registry • Contact me: • Twitter @j0ffrey • GitHub @shin- • E-mail joffrey@docker.com THANK YOU! Resources

×