Docker Private Registry on [CentOS | RHEL] 6.5

If you followed my first post and have Docker 0.7 running locally, you will want to start creating filesystems to distribute to your other machines.  Here are the steps I used to create a local registry.  I recommend you use a different machine (VM) to set this up to test how it would work in production.

  1. Download the CentOS 6.5 Minimal Release
  2. Install CentOS 6.5 with all of the defaults
  3. Install the EPEL Repository
    rpm -Uvh
  4. Install the required RPMs
    yum install python-setuptools python-gevent python-gunicorn python-flask \ 
     python-werkzeug python-urllib3 python-six python-ordereddict python-chardet \
     python-backports-ssl_match_hostname python-backports python-requests \
     python-redis python-blinker python-yaml python-simplejson pyliblzma \
  5. Install Python Eggs with Easy Install
    easy_install rsa
    easy_install pyasn1
  6. Install git RPM
    yum install git
  7. Change our working directory
    cd /var/opt
  8. Clone the docker-registry git repository
    git clone
  9. Change our working directory
    cd docker-registry
  10. Modify the config_sample.yml file for local usage
    cp config/config_sample.yml config/config.yml
    vi config/config.yml
     storage: local
     storage_path: /tmp/registry
     loglevel: debug
  11. Create our registry directory (make sure you have enough space here)
    mkdir /tmp/registry
    chmod 777 /tmp/registry
  12. Stop the firewall (on your own to set this up if you want to use it)
    /etc/init.d/iptables stop
  13. Let’s start the registry
    cd /var/opt/docker-registry
    gunicorn --access-logfile - --log-level debug --debug \
     -b -c config/ \
     -w 1 wsgi:application

Now to test uploading to our registry, go to your machine where you installed docker.

  1. Edit the /etc/hosts file and create an entry for your registry
    vi /etc/hosts
    ==   localhost localhost.localdomain
     ::1         localhost localhost.localdomain   docker-repo
  2. Let’s tag the filesystem that we created in the last post
    docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    leefaus/centos      6.5                 e01162255bbf        21 hours ago        127.3 MB
    docker tag e01162255bbf docker-repo:8000/centos
  3. Push our tag to our registry server
    docker push docker-repo:8000/centos
    The push refers to a repository [docker-repo:8000/centos] (len: 1)
    Sending image list
    Pushing repository docker-repo:8000/centos (1 tags)
    e01162255bbf: Pushing [=================================================> ] 134.5 MB/135 MB 0
    Pushing tags for rev [e01162255bbf] on {http://docker-repo:8000/v1/repositories/centos/tags/latest}
  4. Success!  Now let’s delete our images/containers and try to download from the registry.
    docker rm $(docker ps -a -q)
    docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    leefaus/centos      6.5                 e01162255bbf        21 hours ago        127.3 MB
    docker rmi e01162255bbf
  5. Let’s pull from the registry
    docker pull docker-repo:8000/centos
    Pulling repository docker-repo:8000/centos
    e01162255bbf: Download complete
  6. Let’s check that it is there
    docker images
    REPOSITORY                TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    docker-repo:8000/centos   latest              e01162255bbf        21 hours ago        127.3 MB==
  7. Let’s start it up
    docker run docker-repo:8000/centos cat /etc/hosts

2 thoughts on “Docker Private Registry on [CentOS | RHEL] 6.5

  1. Interesting article. I’m left to question, though, is there a benefit to running the Registry itself outside of a container?

    One of the benefits of Docker, is that this blog post *could* be written as

    1) Install Docker
    2) docker run -p 5000 stackbrew/registry
    3) Your steps about uploading..

    • Nick,

      I agree completely that this would be the ultimate way of using the registry. Unfortunately, the company I was consulting for would allow us to download the FS from the public repo and we needed to build everything from scratch. We struggled getting all of the right bits in place from different blog posts, so we tore some of the code apart to see what was really going on. This post was more about what we learned so if someone else had the need they wouldn’t need to go through the same pain.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: