Docker Registry Private Warehouse build Detailed steps _docker

Source: Internet
Author: User
Tags socket error git clone docker registry

Docker Registry Private Warehouse Build

The authorities have already provided many versions of the Linux image, which can be downloaded directly from the official warehouse (public repositories). If security and speed are considered, we may want to set up a private warehouse in our local area network (private repositories) to put our own mirrors, docker-registry is the tool we need.

This construction

Docker-registry Server (Dev) (v0.9.0)

Add Docker Users and directories

For security reasons, we can add a user docker, use this non-root user to allow the Docker registry program, and specify the location where the Docker mirror is stored, designated as the/home/docker_registry directory

Useradd Docker
mkdir-p/home/docker_registry
chown-r docker.docker/home/docker_registry/

Clone the latest version of registry from GitHub, enter the CONFIG subdirectory under this directory, and copy a profile from the template:

git clone https://github.com/docker/docker-registry.git
CD docker-registry/config
CP config_sample.yml Config.yml

This config.yml configuration file can be modified at this time, and you need to be aware of the following two places:

#配置sqlite数据库位置
sqlalchemy_index_database: _env:sqlalchemy_index_database:sqlite:////home/docker_registry/ Docker-registry.db
#配置本地存储位置 local
: &local
  storage:local
  storage_path: _env:storage_path:/ Home/docker_registry

Install some of the necessary software packages and some docker-registry Python tools and libraries to use:

Apt-get Update
apt-get install build-essential python-dev liblzma-dev libevent-dev python-pip Libssl-dev

You will often be prompted to insert a Netinst disc when you install the package using Apt-get:

Media change:please Insert the disc labeled

When there is no time to install, you can open the file/etc/apt/sources.list file, comment out the CDROM line,

Then execute apt-get update to the Deb Warehouse,

This will not search for CDROM again when you use Apt-get installation later.

Modify Hosts file plus domain name

Vim/etc/hosts
127.0.0.1 docker.registry.com

Install Nginx

Apt-get install nginx
#配置Nginx config
vim/etc/nginx/nginx.conf
User Www-data;
Worker_processes 4;

Pid/run/nginx.pid;
  Events {worker_connections 768;
# multi_accept on;
  } http {# # Basic Settings # # sendfile on;
  Tcp_nopush on;
  Tcp_nodelay on;
  Keepalive_timeout 65;
  Types_hash_max_size 2048;

  # Server_tokens off;
  # Server_names_hash_bucket_size 64;

  # server_name_in_redirect off;
  Include/etc/nginx/mime.types;

  Default_type Application/octet-stream;
  # # # Logging Settings # # Access_log/var/log/nginx/access.log;

  Error_log/var/log/nginx/error.log;
  # # gzip Settings # gzip on;

  Gzip_disable "Msie6";
  # gzip_vary on;
  # gzip_proxied any;
  # Gzip_comp_level 6;
  # gzip_buffers 8k;
  # Gzip_http_version 1.1; # gzip_types Text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+

  RSS Text/javascript; 

  # # # nginx-naxsi Config # # uncomment it if you installed Nginx-naxsi # # #include/etc/nginx/naxsi_core.rules; # # # NGINX-PASsenger Config # # uncomment it if you installed Nginx-passenger # # #passenger_root/usr;

  #passenger_ruby/usr/bin/ruby;
  # # Virtual Host configs # # include/etc/nginx/conf.d/*.conf;
  
  include/etc/nginx/sites-enabled/*;
  Upstream Docker-registry {server localhost:5000;
   } server {Listen 80;
 
   server_name docker.registry.com;  Proxy_set_header Host $http _host; # Required for Docker client ' s sake proxy_set_header x-real-ip $remote _addr; # Pass on real client ' s IP client_max_body_size 0; # Disable any limits to avoid HTTP 413 for large image uploads # 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;

 }
  }
}

Start Nginx

Service Nginx Start

accessing browser tests

http://192.168.124.130/


Installing Python dependencies

Cd/opt/docker-registry
pip install.

If present: Cannot connect to proxy. Socket error: [Errno-2] Name or service not known.

Manually install dependent package plus agent parameters

Pip Install-i http://pypi.v2ex.com/simple.
#注销下面的 pip install. Install all
--pip install-i http://pypi.v2ex.com/simple Gunicorn

Establish a soft connection

Ln-s/usr/local/bin/gunicorn/usr/bin/gunicorn

After the Nginx is started, use the Docker user to perform the following command to test the startup:

Gunicorn--access-logfile---error-logfile-K gevent-b 0.0.0.0:5000-w 8--max-requests cation
Access browser

Http://docker.registry.com


If you see the following output, it indicates that the Docker registry installation was successful

Assign permissions to the database under the directory, or you will not be able to write the database when uploading files

chmod 777/home/docker_registry/repositories/docker-registry.db

Using Supervisord for process monitoring

Apt-get Install Supervisor

Configure supervisor [Docker-registry]

Vim/etc/supervisor/conf.d/docker-registry.conf

[Program:docker-registry]
Directory=/opt/docker-registry
#使用docker用户
user=docker
Command=/usr/local/bin/gunicorn-- Access-logfile---error-logfile-K gevent-b 0.0.0.0:5000-w 8--max-requests--graceful-timeout 3600-t 3600-Docke R_registry.wsgi:application 
redirect_stderr=true
stderr_logfile=none
stdout_logfile=/var/log/ Supervisor/docker-registry.log
autostart=true
autorestart=true
#重新加载 Supervisor Configuration:
supervisorctl
supervisor> reread
docker-registry:available
supervisor> Update
docker-registry:added Process group
supervisor> status
docker-registry  RUNNING  pid 4371, uptime 0:00:01

Viewing port occupancy

NETSTAT-APN | grep 5000

Start the reboot

Service Supervisor Start
#/etc/init.d/supervisord {Start|stop|restart|force-reload|status|force-stop}

Thank you for reading, I hope to help you, thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.