SlideShare a Scribd company logo
1 of 21
Download to read offline
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. More! 
3. Extending the code
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
What’s a registry? 
• Several storage backends supported 
• Filesystem 
• Boto (S3, Google Compute, ...) 
• OpenStack Swift
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!
Search index 
Enabling a basic search index is easy! 
docker run -d -p 5000:5000 -e 
SEARCH_BACKEND=sqlalchemy registry:0.8.1
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
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
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!
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 
$ docker push myregistry.com/busybox:latest 
$ docker pull busybox:buildroot-2014.02 
...
Mirroring 
Better method: Enable mirroring on your registry! 
ENV MIRROR_SOURCE https://registry-1.docker.io 
ENV MIRROR_SOURCE_INDEX https://index.docker.io
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!
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
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
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!
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
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.
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!
• 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

More Related Content

What's hot

What's hot (20)

Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Docker networking Tutorial 101
Docker networking Tutorial 101Docker networking Tutorial 101
Docker networking Tutorial 101
 
Docker Birthday #3 - Intro to Docker Slides
Docker Birthday #3 - Intro to Docker SlidesDocker Birthday #3 - Intro to Docker Slides
Docker Birthday #3 - Intro to Docker Slides
 
Docker.pptx
Docker.pptxDocker.pptx
Docker.pptx
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Getting started with Docker
Getting started with DockerGetting started with Docker
Getting started with Docker
 
Kubernetes in Docker
Kubernetes in DockerKubernetes in Docker
Kubernetes in Docker
 
What is Docker
What is DockerWhat is Docker
What is Docker
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefits
 
Kubernetes Architecture
 Kubernetes Architecture Kubernetes Architecture
Kubernetes Architecture
 
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
 
Docker
DockerDocker
Docker
 
Docker intro
Docker introDocker intro
Docker intro
 
Docker Networking: Control plane and Data plane
Docker Networking: Control plane and Data planeDocker Networking: Control plane and Data plane
Docker Networking: Control plane and Data plane
 
Docker 101: An Introduction
Docker 101: An IntroductionDocker 101: An Introduction
Docker 101: An Introduction
 
Docker vs VM | | Containerization or Virtualization - The Differences | DevOp...
Docker vs VM | | Containerization or Virtualization - The Differences | DevOp...Docker vs VM | | Containerization or Virtualization - The Differences | DevOp...
Docker vs VM | | Containerization or Virtualization - The Differences | DevOp...
 
Introduction to docker and docker compose
Introduction to docker and docker composeIntroduction to docker and docker compose
Introduction to docker and docker compose
 
Introduction to Docker - 2017
Introduction to Docker - 2017Introduction to Docker - 2017
Introduction to Docker - 2017
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
 

Similar to Docker Advanced registry usage

How to Use Your Own Private Registry
How to Use Your Own Private RegistryHow to Use Your Own Private Registry
How to Use Your Own Private Registry
Docker, Inc.
 
Kubernetes Story - Day 2: Quay.io Container Registry for Publishing, Building...
Kubernetes Story - Day 2: Quay.io Container Registry for Publishing, Building...Kubernetes Story - Day 2: Quay.io Container Registry for Publishing, Building...
Kubernetes Story - Day 2: Quay.io Container Registry for Publishing, Building...
Mihai Criveti
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
Hannes Hapke
 
A new model for Docker image distribution
A new model for Docker image distributionA new model for Docker image distribution
A new model for Docker image distribution
Docker, Inc.
 
Practical introduction to dev ops with chef
Practical introduction to dev ops with chefPractical introduction to dev ops with chef
Practical introduction to dev ops with chef
LeanDog
 

Similar to Docker Advanced registry usage (20)

Docker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registryDocker worshop @Twitter - How to use your own private registry
Docker worshop @Twitter - How to use your own private registry
 
How to Use Your Own Private Registry
How to Use Your Own Private RegistryHow to Use Your Own Private Registry
How to Use Your Own Private Registry
 
Docker module 1
Docker module 1Docker module 1
Docker module 1
 
Kubernetes Story - Day 2: Quay.io Container Registry for Publishing, Building...
Kubernetes Story - Day 2: Quay.io Container Registry for Publishing, Building...Kubernetes Story - Day 2: Quay.io Container Registry for Publishing, Building...
Kubernetes Story - Day 2: Quay.io Container Registry for Publishing, Building...
 
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, OrchestrationThe Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
 
Docker 102 - Immutable Infrastructure
Docker 102 - Immutable InfrastructureDocker 102 - Immutable Infrastructure
Docker 102 - Immutable Infrastructure
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
 
DevOPS training - Day 2/2
DevOPS training - Day 2/2DevOPS training - Day 2/2
DevOPS training - Day 2/2
 
Package your Java EE Application using Docker and Kubernetes
Package your Java EE Application using Docker and KubernetesPackage your Java EE Application using Docker and Kubernetes
Package your Java EE Application using Docker and Kubernetes
 
Getting Started with Docker
Getting Started with DockerGetting Started with Docker
Getting Started with Docker
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
 
habitat at docker bud
habitat at docker budhabitat at docker bud
habitat at docker bud
 
A new model for Docker image distribution
A new model for Docker image distributionA new model for Docker image distribution
A new model for Docker image distribution
 
ITB2017 - Keynote
ITB2017 - KeynoteITB2017 - Keynote
ITB2017 - Keynote
 
Docker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on Azure
Docker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on AzureDocker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on Azure
Docker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on Azure
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
 
Docker for Ruby Developers
Docker for Ruby DevelopersDocker for Ruby Developers
Docker for Ruby Developers
 
Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure
Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure
Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure
 
Practical introduction to dev ops with chef
Practical introduction to dev ops with chefPractical introduction to dev ops with chef
Practical introduction to dev ops with chef
 

More from Docker, Inc.

Build & Deploy Multi-Container Applications to AWS
Build & Deploy Multi-Container Applications to AWSBuild & Deploy Multi-Container Applications to AWS
Build & Deploy Multi-Container Applications to AWS
Docker, Inc.
 
Build & Deploy Multi-Container Applications to AWS
Build & Deploy Multi-Container Applications to AWSBuild & Deploy Multi-Container Applications to AWS
Build & Deploy Multi-Container Applications to AWS
Docker, Inc.
 

More from Docker, Inc. (20)

Containerize Your Game Server for the Best Multiplayer Experience
Containerize Your Game Server for the Best Multiplayer Experience Containerize Your Game Server for the Best Multiplayer Experience
Containerize Your Game Server for the Best Multiplayer Experience
 
How to Improve Your Image Builds Using Advance Docker Build
How to Improve Your Image Builds Using Advance Docker BuildHow to Improve Your Image Builds Using Advance Docker Build
How to Improve Your Image Builds Using Advance Docker Build
 
Build & Deploy Multi-Container Applications to AWS
Build & Deploy Multi-Container Applications to AWSBuild & Deploy Multi-Container Applications to AWS
Build & Deploy Multi-Container Applications to AWS
 
Securing Your Containerized Applications with NGINX
Securing Your Containerized Applications with NGINXSecuring Your Containerized Applications with NGINX
Securing Your Containerized Applications with NGINX
 
How To Build and Run Node Apps with Docker and Compose
How To Build and Run Node Apps with Docker and ComposeHow To Build and Run Node Apps with Docker and Compose
How To Build and Run Node Apps with Docker and Compose
 
Hands-on Helm
Hands-on Helm Hands-on Helm
Hands-on Helm
 
Distributed Deep Learning with Docker at Salesforce
Distributed Deep Learning with Docker at SalesforceDistributed Deep Learning with Docker at Salesforce
Distributed Deep Learning with Docker at Salesforce
 
The First 10M Pulls: Building The Official Curl Image for Docker Hub
The First 10M Pulls: Building The Official Curl Image for Docker HubThe First 10M Pulls: Building The Official Curl Image for Docker Hub
The First 10M Pulls: Building The Official Curl Image for Docker Hub
 
Monitoring in a Microservices World
Monitoring in a Microservices WorldMonitoring in a Microservices World
Monitoring in a Microservices World
 
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
 
Predicting Space Weather with Docker
Predicting Space Weather with DockerPredicting Space Weather with Docker
Predicting Space Weather with Docker
 
Become a Docker Power User With Microsoft Visual Studio Code
Become a Docker Power User With Microsoft Visual Studio CodeBecome a Docker Power User With Microsoft Visual Studio Code
Become a Docker Power User With Microsoft Visual Studio Code
 
How to Use Mirroring and Caching to Optimize your Container Registry
How to Use Mirroring and Caching to Optimize your Container RegistryHow to Use Mirroring and Caching to Optimize your Container Registry
How to Use Mirroring and Caching to Optimize your Container Registry
 
Monolithic to Microservices + Docker = SDLC on Steroids!
Monolithic to Microservices + Docker = SDLC on Steroids!Monolithic to Microservices + Docker = SDLC on Steroids!
Monolithic to Microservices + Docker = SDLC on Steroids!
 
Kubernetes at Datadog Scale
Kubernetes at Datadog ScaleKubernetes at Datadog Scale
Kubernetes at Datadog Scale
 
Labels, Labels, Labels
Labels, Labels, Labels Labels, Labels, Labels
Labels, Labels, Labels
 
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment ModelUsing Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
 
Build & Deploy Multi-Container Applications to AWS
Build & Deploy Multi-Container Applications to AWSBuild & Deploy Multi-Container Applications to AWS
Build & Deploy Multi-Container Applications to AWS
 
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
 
Developing with Docker for the Arm Architecture
Developing with Docker for the Arm ArchitectureDeveloping with Docker for the Arm Architecture
Developing with Docker for the Arm Architecture
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

Docker Advanced registry usage

  • 1. Docker: Advanced registry usage September 17th, 2014 in Freiburg
  • 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. 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. What’s a registry? • Several storage backends supported • Filesystem • Boto (S3, Google Compute, ...) • OpenStack Swift
  • 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. Search index Enabling a basic search index is easy! docker run -d -p 5000:5000 -e SEARCH_BACKEND=sqlalchemy registry:0.8.1
  • 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. 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. 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. Search index Don’t like SQLite? That’s fine too!
  • 11. Mirroring Having a local copy of commonly used images can be very helpful!
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. • 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