---
# A Practical Introduction to the Docker Registry Server

**URL:** https://crunchtools.com/practical-docker-registry/
Date: 2014-10-28
Author: fatherlinux
Post Type: post
Summary: Background One of the key advantages of using Docker is it’s centralized image management server, called a Registry Server. The Docker project, as well as Red Hat, maintain public registry servers which host supported images. The Docker project also provides an Open Source version of the Registry server which can be deployed on premise inContinue Reading "A Practical Introduction to the Docker Registry Server" →
Categories: Articles
Tags: Container Tools, DevOps, Fedora, RHEL, Systems Administration, Tutorials
---

# Background

One of the key advantages of using Docker is it's centralized image management server, called a [Registry Server](https://github.com/dotcloud/docker-registry). The Docker project, as well as Red Hat, maintain public registry servers which host supported images. The Docker project also provides an Open Source version of the Registry server which can be deployed on premise in your own network.

## Why

As I mentioned in my original [article](http://crunchtools.com/a-practical-introduction-to-docker-containers/), one of the first things a user wants to do after learning about Docker, is fire up a Registry server. This allows one to create derivative works with Docker files, and push them somewhere to be consumed again and again, by themselves and others.

 

## What

### Use Cases

 	- I have pulled the offical RHEL or Fedora image, modified it with a Dockerfile and now I want to save it somewhere.

 	- I need a place to share the images I have created with others

 	- I want something that is easy to maintain and upgrade

## Architecture

A containerized version of the the [Docker Registry](https://registry.hub.docker.com/_/registry/) is provided by the Docker team. This server is written in Python and the version at the time of this writing was 0.8.1. This server is now being referred to as the V1 server. It's important to not that this server is delivered as a Docker image.

The V1 Docker Registry Server has been recently put into [maintenance](https://github.com/docker/docker-registry/issues/612) because the V2 server will now be where active development happens. That said, the V1 Registry server will be the current stable version for the foreseeable future and will receive security patches, etc.

 

# Basic Operations

## Install the Registry Container

The Docker Registry server provided as a repository with layers for each version released

docker pull registry
docker images registry

Output:
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
registry            0.8.1               3e7767ddd728        3 days ago          427.9 MB
registry            0.7.3               c723c9b95ac0        3 days ago          424.1 MB
registry            latest              8e9a29f977a7        3 days ago          427.9 MB
registry            0.6.9               bee70978874c        3 days ago          461.9 MB
registry            0.8.0               cd3581c06bdc        10 weeks ago        442.5 MB
registry            0.6.8               346f0c4d40c3        4 months ago        447.8 MB
registry            0.7.2               8b65881eed3d        4 months ago        516 MB
registry            0.7.0               a6a394071526        4 months ago        516 MB
registry            0.7.1               cc32522f16d6        4 months ago        516 MB
registry            0.6.7               cd8d7a6d86d1        5 months ago        452.5 MB
registry            0.6.6               e260f5a77e52        6 months ago        443 MB
registry            0.6.5               e7bac0a3804b        6 months ago        433 MB
registry            0.6.3               1f7bbd131cd8        8 months ago        490 MB
registry            0.6.2               0b520d776e7d        8 months ago        466.6 MB
registry            0.6.1               9f98cb899f46        8 months ago        460.1 MB
registry            0.6.0               873f518b98ef        8 months ago        466.5 MB
registry            0.5.9               e8e5377f8307        8 months ago        466.3 MB
registry            0.6.4               b04ace768d59        8 months ago        490 MB

## Basic Deployment

This will manually start the container in daemon mode. Notice the -p option will map port 5000 in the container to the underlying operating system. This means you will access the registry server as if it is installed and running on the underlying OS.
`docker run -d -p 5000:5000 registry:latest`

# Advanced Operations

## Registry Deployment (Manual)

This will create a fairly functional Registry container that can be used for longer term hosting of repositories. The -e option sets an environmental variable inside the container, while the -v option maps a volume into the Docker container

`docker run -d -p 5000:5000 -e SEARCH_BACKEND=sqlalchemy -e DOCKER_REGISTRY_CONFIG=/srv/docker/conf.d/config.yml -v /srv/docker/registry:/srv/docker/registry -v /srv/docker/conf.d:/srv/docker/conf.d registry`

## Registry Deployment on RHEL7 (Container)

Create a unit file

[Unit]
Description=Containerized Registry server for Docker

[Service]
Type=simple
ExecStart=/usr/bin/docker run -d -p 5000:5000 -e SEARCH_BACKEND=sqlalchemy -e DOCKER_REGISTRY_CONFIG=/srv/docker/conf.d/config.yml -v /srv/docker/registry:/srv/docker/registry -v /srv/docker/conf.d:/srv/docker/conf.d --name=docker-registry-container registry
ExecStop=/usr/bin/docker stop docker-registry-container
ExecStopPost=/usr/bin/docker rm docker-registry-container
RemainAfterExit=yes
Restart=no

[Install]
WantedBy=multi-user.target

## Registry Deployment on RHEL6 (Container)

To deploy on RHEL6, it is necessary to create an init script similar to the following

#!/bin/sh
#
# docker-registry-container: ran as a container
#
# chkconfig:   345 95 5
# description: Runs Docker Registry server as a container

# Source function library.
. /etc/rc.d/init.d/functions

prog="docker-registry-container"

start() {
echo -n $"Starting $prog: "
/usr/bin/docker run -d -p 5000:5000 -e SEARCH_BACKEND=sqlalchemy -e DOCKER_REGISTRY_CONFIG=/srv/docker/conf.d/config.yml -v /srv/docker/registry:/srv/docker/registry -v /srv/docker/conf.d:/srv/docker/conf.d --name=docker-registry-container registry
}

stop() {
echo -n $"Stopping $prog: "
/usr/bin/docker stop docker-registry-container
/usr/bin/docker rm docker-registry-container
}

restart() {
stop
start
}

status() {
/usr/bin/docker ps docker-registry-container
}

case "$1" in
start)
$1
;;
stop)
$1
;;
restart)
$1
;;
status)
$1
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac
exit $?

## Registry Deployment on RHEL7 (RPM Package)

The Docker Registry server is also provided as an RPM with configuration in a manner similar to other RHEL services.

Install Docker Registry

`yum install -y docker-registry`
Create custom data directory

`mkdir -p /srv/docker/data`
Modify the configuration file

`vim /etc/docker-registry.yml`

dev:
storage: local
storage_path: /srv/docker/data
loglevel: debug
Enable and start service

systemctl enable docker-registry.service
systemctl start docker-registry.service

---

## Categories

- Articles

---

## Navigation

- [Home](https://crunchtools.com/)
- [Articles](https://crunchtools.com/category/articles/)
- [Events](https://crunchtools.com/category/events/)
- [News](https://crunchtools.com/category/news/)
- [Presentations](https://crunchtools.com/category/presentations/)
- [Software](https://crunchtools.com/software/)
- [Beaver Backup](https://crunchtools.com/software/beaver-backup/)
- [Check BGP Neighbors](https://crunchtools.com/software/check-bgp-neighbors-nagios/)
- [Chev](https://crunchtools.com/software/chev-check-vulnerabilities-script/)
- [Graph BGP Neighbors](https://crunchtools.com/software/grpah-bgp-neighbors/)
- [Graph MySQL Stats](https://crunchtools.com/software/graph-mysql-stats/)
- [Graph Sockets Pipes Files](https://crunchtools.com/software/graph-sockets-pipes-files/)
- [MCP Servers](https://crunchtools.com/software/mcp-servers/)
- [Petit](https://crunchtools.com/software/petit/)
- [Racecar](https://crunchtools.com/software/racecar/)
- [Shiva](https://crunchtools.com/software/shiva/)
- [About](https://crunchtools.com/about/)
- [Home](https://crunchtools.com)

## Tags

- Container Tools
- DevOps
- Fedora
- RHEL
- Systems Administration
- Tutorials