Skip to content

Instantly share code, notes, and snippets.

@nkwhr
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkwhr/19259c9de83af8391b92 to your computer and use it in GitHub Desktop.
Save nkwhr/19259c9de83af8391b92 to your computer and use it in GitHub Desktop.
How to setup and run private docker registry with Nginx and fig on CentOS6

Download registry container

$ docker pull registry

Install fig

$ sudo yum install python-pip
$ sudo pip install -U fig

Configure fig.yaml

web:
  image: registry
  ports:
    - "5000:5000"
  volumes:
    - "~/data/registry:/registry"
  environment:
    - STORAGE_PATH=/registry

Configure Nginx

upstream docker-registry {
  server localhost:5000;
}

server {
  listen 80;
  server_name docker-registry.exmple.com;

  proxy_set_header Host       $http_host;
  proxy_set_header X-Real-IP  $remote_addr;

  client_max_body_size 0;

  # required to avoid HTTP 411: see Issue #1486 (https://github.com/dotcloud/docker/issues/1486)
  chunked_transfer_encoding on;

  location / {
    proxy_pass http://docker-registry;
  }

  location /_ping {
    auth_basic off;
    proxy_pass http://docker-registry;
  }

  location /v1/_ping {
    auth_basic off;
    proxy_pass http://docker-registry;
  }
}

Start Nginx

$ sudo nginx -t
$ sudo service nginx start

Run container with fig

$ fig up

Allow insecure-registry

# in /etc/sysconfig/docker

other_args='--insecure-registry docker-registry.example.com'

Restart Docker

$ sudo service docker restart

Add tag to a container image

$ docker tag nkwhr/my_app docker-registry.example.com/my_app

Push container image

$ docker push docker-registry.example.com/my_app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment