Deployment and use of Enterprise docker Private Warehouse harbor on Ubuntu14.04
Introduction to Harbor:
In short, Harbor is an enterprise-level Docker Registry that implements private storage of p_w_picpaths and log statistics permission control, and supports the creation of multiple projects (Harbor's concept), based on the official Registry V2 implementation.
II. Deployment methods:
Operating System: Ubuntu 14.04
1. Install docker:
#install plugin sudo apt-get install apt-transport-https ca-certificates#add GPG keysudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net: 80--recv-keys 58118E89F3A912897C070ADBF76221572C52609Dsudo vim /etc/apt/s sources.list.d/docker.list#Add the following content, save exit deb https://apt.dockerproject.org/repo ubuntu-trusty main#Follow new, Remove old reposudo apt-get updatesudo apt-get purge lxc-docker#install docker-enginesudo apt-get install docker-engine
2. Install docker-com:
sudo curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > /home/cimer/docker-composesudo mv docker-compose /usr/local/bin/sudo chmod +x /usr/local/bin/docker-compose
3. Installation of Harbor:
3.1 Clone source code:
git clone https://github.com/vmware/harbor
3.2, modify configuration:
cd harbor/Deploy/vim harbor.cfg
As follows:
## Configuration file of Harbor#The IP address or hostname to access admin UI and registry service.# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.# hostname = 172.16.4.253#The protocol for accessing the UI and token/notification service, by default it is http.# It can be set to https if ssl is enabled on nginx.# URL access method, SSL needs to configure nginxui_url_protocol = http#Email account settings for sending out password resetting emails.# email_server = smtp.xxxxxx.comemail_server_port = 465email_username = reg@mritd.meemail_password = xxemail_from = docker email_ssl = true##The password of Harbor admin, change this before any production use.# By default the auth mode is db_auth, i.e. the credentials are stored in a local database.# Set it to ldap_auth if you want to verify a user's credentials against an LDAP server.# Specify the permission authentication method of Harbor. Harbor supports local mysql data storage password, and also supports LDAPauth_mode = db_auth#The url for an ldap endpoint.# ldap_url = ldaps://ldap.mydomain.com#The basedn template to look up a user in LDAP and verify the user's password.# ldap_basedn = uid=%s,ou=people,dc=mydomain,dc=com#The password for the root user of mysql db, change this before any production use.# mysql database root account password db_password = root123#Turn on or off the self-registration feature#Allow open registration self_registration = on#Turn on or off the customize your particular #Allow self-signed certificates customize_crt = on#fill in your particular message#Self-signed certificate information crt_country = CNcrt_state = Statert_location = CNcrt_organization = mritdcrt_organizationalunit = mritdcrt_commonname = mritd.mecrt_email = reg.mritd.me#####
3.3 Generate relevant configuration files:
cd harbor/Deploy/./ prepare
3.4 Compile p_w_picpath and start:
cd harbor/Deploy/docker-compose up -d
3.5 Check relevant containers after startup:
Proxy : A reverse proxy composed of Nginx servers
Registry : A container instance composed of Docker's official open source registry image
UI : core services in the architecture, the code that makes up this container is the body of the Harbor project
Mysql : Database container consisting of official Mysql images
Log : The container running rsyd collects logs from other containers via log-driver
4. Visit Web UI:
Access: http://172.16.4.253, account password is configured in harbor.cfg
If self_registration in harbor.cfg is set to off, normal users cannot register, and only administrators can create users; the register button in the upper right corner will also disappear.
4.2, login:
Default password: admin: Harbor12345
4.3 Creating a Private Project:
harbor projects are similar to Docker Hub usernames, under which many images can be stored
4.4 push mirror:
View in web ui
Note: If validation is not applicable, modify the registry configuration file, comment out the auth section, and restart
sudo vim harbor/Deploy/config/registry/config.ymlsudo docker-compose stopsudo docker-compose up -d
Third, configure docker image replication:
The replication function is the replication of p_w_picpath between two or more harbor nodes. The schematic diagram is as follows:
1. First configure 2 harbor instances, 172.16.4.253 and 172.16.4.252 respectively.
2. Upload a mirror on 172.16.4.253, with this instance as the primary node
3. Go to the web ui project options and select Copy:
4. Click Add Policy and set policy:
After creation, we can see that there is one more policy in the replication policy and one more task in the replication task. After a while, the replication can be completed. Log in to web ui for 172.16.4.252 and you'll see that mirrors and logs are copied over.
Fourth, upgrade harbor:
1. Delete the original container
cd harbor/Deploy/sudo docker-compose down
2. backup
mv harbor/ /tm/harbor
3. Download the source code again
git clone https://github.com/vmware/harbor
4. If Harbor is migrating to another server, perform a data backup first
cd harbor/migration/
After modifying the database account password in the migration.cfg file
sudo docker build -t migrate-tool .
5. Run a temporary database container (note: /data/database is the directory where you set up the mount database/path/to/backup directory for data backup) with this subset of data
sudo docker run -ti --rm -v /data/database:/var/lib/mysql -v /path/to/backup:/harbor-migration/backup migrate-tool backup
6. database restore
sudo docker run -ti --rm -v /data/database:/var/lib/mysql migrate-tool up head
7. Compare profiles
If you modify the port, you must update the port in cd harbor/Deploy/config/nginx/nginx.conf
diff harbor.cfg /tmp/harbor/Deploy/harbor.cfgdiff docker-compose.yaml /tmp/harbor/Deploy/docker-compose.yaml
8. Implementation of.../ prepare Generate a new profile
cd /harbor/Deploy/./ prepare
9.build New image, boot container
cd /harbor/Deploy/docker-compose up --build -d
After completion, log in to the web ui and check if the upgrade was successful.
Reference:
https://my.oschina.net/u/1540325/blog/702260
http://www.cnblogs.com/jicki/p/5737369.html
http://blog.csdn.net/project_harbor/article/details/51261934
http://www.tuicool.com/articles/m2uyQri
http://www.2cto.com/net/201607/531849.html