harbor/docs/user_guide.md

182 lines
8.9 KiB
Markdown
Raw Normal View History

2016-03-07 10:39:36 +01:00
#User Guide
##Overview
2016-11-07 14:53:46 +01:00
This guide walks you through the fundamentals of using Harbor. You'll learn how to use Harbor to:
2016-03-07 10:39:36 +01:00
2016-03-08 08:11:39 +01:00
* Manage your projects.
* Manage members of a project.
2016-06-28 07:47:31 +02:00
* Replicate projects to a remote registry.
2016-03-08 08:11:39 +01:00
* Search projects and repositories.
2016-06-28 07:47:31 +02:00
* Manage Harbor system if you are the system administrator:
+ Manage users.
2016-06-29 05:23:58 +02:00
+ Manage destinations.
+ Manage replication policies.
2016-03-08 08:11:39 +01:00
* Pull and push images using Docker client.
2016-11-07 14:53:46 +01:00
* Delete repositories and images.
2016-03-07 10:39:36 +01:00
##Role Based Access Control
RBAC (Role Based Access Control) is provided in Harbor and there are four roles with different privileges:
* **Guest**: Guest has read-only privilege for a specified project.
* **Developer**: Developer has read and write privileges for a project.
2016-03-08 04:58:48 +01:00
* **ProjectAdmin**: When creating a new project, you will be assigned the "ProjectAdmin" role to the project. Besides read-write privileges, the "ProjectAdmin" also has some management privileges, such as adding and removing members.
2016-03-07 10:39:36 +01:00
* **SysAdmin**: "SysAdmin" has the most privileges. In addition to the privileges mentioned above, "SysAdmin" can also list all projects, set an ordinary user as administrator and delete users. The public project "library" is also owned by the administrator.
2016-03-08 06:54:53 +01:00
* **Anonymous**: When a user is not logged in, the user is considered as an "anonymous" user. An anonymous user has no access to private projects and has read-only access to public projects.
2016-03-07 10:39:36 +01:00
2016-03-08 06:54:53 +01:00
##User account
As a new user, you can sign up an account by going through the self-registration process. The username and email must be unique in the Harbor system. The password must contain at least 7 characters with 1 lowercase letter, 1 uppercase letter and 1 numeric character.
If the administrator has configured LDAP/AD as authentication source, no sign-up is required. The LDAP/AD user id can be used directly to log in to Harbor.
2016-03-08 04:58:48 +01:00
2016-03-08 06:54:53 +01:00
When you forgot your password, you can follow the below steps to reset the password:
2016-03-08 04:58:48 +01:00
1. Click the link "forgot password" in the sign in page.
2016-03-08 06:54:53 +01:00
2. Input the email used when you signed up, an email will be sent out to you.
3. After receiving the email, click on the link in the email which directs you to a password reset web page.
2016-03-08 04:58:48 +01:00
4. Input your new password and click "Submit".
2016-03-07 10:39:36 +01:00
##Managing projects
2016-03-08 04:58:48 +01:00
A project in Harbor contains all repositories of an application. RBAC is applied to a project. There are two types of projects in Harbor:
2016-03-07 10:39:36 +01:00
* **Public**: All users have the read privilege to a public project, it's convenient for you to share some repositories with others in this way.
2016-03-08 06:54:53 +01:00
* **Private**: A private project can only be accessed by users with proper privileges.
2016-03-07 10:39:36 +01:00
2016-06-29 07:30:18 +02:00
You can create a project after you signed in. Enabling the "Public" checkbox will make this project public.
2016-03-07 10:39:36 +01:00
2016-06-29 06:21:42 +02:00
![create project](img/new_create_project.png)
2016-03-07 10:39:36 +01:00
2016-06-29 07:30:18 +02:00
After the project is created, you can browse repositories, users and logs using the navigation tab.
2016-03-07 10:39:36 +01:00
2016-06-29 06:21:42 +02:00
![browse project](img/new_browse_project.png)
2016-03-07 10:39:36 +01:00
2016-06-29 07:30:18 +02:00
All logs can be listed by clicking "Logs". You can apply a filter by username, or operations and dates under "Advanced Search".
2016-03-08 04:58:48 +01:00
2016-06-29 06:21:42 +02:00
![browse project](img/new_project_log.png)
2016-03-07 10:39:36 +01:00
2016-03-08 04:58:48 +01:00
##Managing members of a project
2016-03-07 10:39:36 +01:00
###Adding members
You can add members with different roles to an existing project.
2016-06-29 06:21:42 +02:00
![browse project](img/new_add_member.png)
2016-03-07 10:39:36 +01:00
###Updating and removing members
2016-03-08 04:58:48 +01:00
You can update or remove a member by clicking the icon on the right.
2016-03-07 10:39:36 +01:00
2016-06-29 06:21:42 +02:00
![browse project](img/new_remove_update_member.png)
2016-03-07 10:39:36 +01:00
2016-06-28 07:47:31 +02:00
##Replicating images
2016-06-29 05:23:58 +02:00
If you are a system administrator, you can replicate images to a remote registry, which is called destination in Harbor. Only Harbor instance is supported as a destination for now.
2016-10-27 08:58:33 +02:00
**Note:** The replication feature is incompatible between Harbor instance before version 0.3.5(included) and after version 0.3.5.
2016-06-29 05:23:58 +02:00
Click "Add New Policy" on the "Replication" tab, fill the necessary fields and click "OK", a policy for this project will be created. If "Enable" is chosen, the project will be replicated to the remote immediately, and when a new repository is pushed to this project or an existing repository is deleted from this project, the same operation will also be replicated to the destination.
2016-06-29 06:21:42 +02:00
![browse project](img/new_create_policy.png)
2016-06-29 05:23:58 +02:00
You can enable or disable a policy in the policy list view, and only the policies which are disbled can be edited.
Click a policy, jobs which belong to this policy will be listed. A job represents the progress which will replicate a repository of one project to the remote.
2016-06-28 07:47:31 +02:00
2016-06-29 06:21:42 +02:00
![browse project](img/new_policy_list.png)
2016-03-07 10:39:36 +01:00
##Searching projects and repositories
2016-06-29 07:30:18 +02:00
Entering a keyword in the search field at the top lists all matching projects and repositories. The search result includes both public and private repositories you have access privilege to.
2016-03-07 10:39:36 +01:00
2016-06-29 06:21:42 +02:00
![browse project](img/new_search.png)
2016-03-07 10:39:36 +01:00
##Administrator options
2016-06-29 05:23:58 +02:00
###Managing user
2016-06-29 07:30:18 +02:00
Administrator can add "administrator" role to an ordinary user by toggling the switch under "Administrator". To delete a user, click on the recycle bin icon.
2016-03-07 10:39:36 +01:00
2016-06-29 06:21:42 +02:00
![browse project](img/new_set_admin_remove_user.png)
2016-03-07 10:39:36 +01:00
2016-06-29 05:23:58 +02:00
###Managing destination
You can list, add, edit and delete destinations in the "Destination" tab. Only destinations which are not referenced by any policies can be edited.
2016-06-28 07:47:31 +02:00
2016-06-29 06:21:42 +02:00
![browse project](img/new_manage_destination.png)
2016-06-29 05:23:58 +02:00
###Managing replication
You can list, edit, enable and disable policies in the "Replication" tab. Make sure the policy is disabled before you edit it.
2016-06-28 07:47:31 +02:00
2016-06-29 06:21:42 +02:00
![browse project](img/new_manage_replication.png)
2016-03-07 10:39:36 +01:00
##Pulling and pushing images using Docker client
2016-03-08 04:58:48 +01:00
**NOTE: Harbor only supports Registry V2 API. You need to use Docker client 1.6.0 or higher.**
Harbor supports HTTP by default and Docker client trys to connect to Harbor using HTTPS first, so if you encounter an error as below when you pull or push images, you need to add '--insecure-registry' option to /etc/default/docker (ubuntu) or /etc/sysconfig/docker (centos):
*FATA[0000] Error response from daemon: v1 ping attempt failed with error:
Get https://myregistrydomain.com:5000/v1/_ping: tls: oversized record received with length 20527.
If this private registry supports only HTTP or HTTPS with an unknown CA certificate,please add
`--insecure-registry myregistrydomain.com:5000` to the daemon's arguments.
In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag;
simply place the CA certificate at /etc/docker/certs.d/myregistrydomain.com:5000/ca.crt*
2016-03-07 10:39:36 +01:00
###Pulling images
2016-03-08 04:58:48 +01:00
If the project that the image belongs to is private, you should sign in first:
2016-03-07 10:39:36 +01:00
```sh
$ docker login 10.117.169.182
```
2016-03-08 04:58:48 +01:00
You can now pull the image:
2016-03-07 10:39:36 +01:00
```sh
$ docker pull 10.117.169.182/library/ubuntu:14.04
```
2016-03-08 04:58:48 +01:00
**Note: Replace "10.117.169.182" with the IP address or domain name of your Harbor node.**
2016-03-07 10:39:36 +01:00
###Pushing images
2016-03-08 04:58:48 +01:00
Before pushing an image, you must create a corresponding project on Harbor web UI.
2016-03-07 10:39:36 +01:00
2016-03-08 04:58:48 +01:00
First, log in from Docker client:
2016-03-07 10:39:36 +01:00
```sh
$ docker login 10.117.169.182
```
2016-03-08 04:58:48 +01:00
Tag the image:
2016-03-07 10:39:36 +01:00
```sh
$ docker tag ubuntu:14.04 10.117.169.182/demo/ubuntu:14.04
```
2016-03-08 04:58:48 +01:00
Push the image:
2016-03-07 10:39:36 +01:00
```sh
$ docker push 10.117.169.182/demo/ubuntu:14.04
```
2016-06-28 07:47:31 +02:00
**Note: Replace "10.117.169.182" with the IP address or domain name of your Harbor node.**
##Deleting repositories
2016-11-07 14:53:46 +01:00
Repository deletion runs in two steps.
2016-11-07 14:58:17 +01:00
2016-11-07 14:53:46 +01:00
First, delete a repository in Harbor's UI. This is soft deletion. You can delete the entire repository or just a tag of it. After the soft deletion,
the repository is no longer managed in Harbor, however, the files of the repository still remains in Harbor's storage.
2016-06-28 07:47:31 +02:00
2016-06-29 06:26:36 +02:00
![browse project](img/new_delete_repository.png)
2016-11-07 14:53:46 +01:00
**CAUTION: If both tag A and tag B refer to the same image, after deleting tag A, B will also get deleted.**
2016-06-28 07:47:31 +02:00
2016-11-07 14:58:17 +01:00
Next, delete the actual files of the repository using the registry's garbage collection(GC). Make sure that no one is pushing images or Harbor is not running at all before you perform a GC. If someone were pushing an image while GC is running, there is a risk that the image's layers will be mistakenly deleted which results in a corrupted image. So before running GC, a preferred approach is to stop Harbor first.
2016-06-29 11:41:26 +02:00
2016-11-10 10:19:35 +01:00
Run the below commands on the host which Harbor is deployed on to preview what files/images will be affected:
2016-06-28 07:47:31 +02:00
```sh
2016-06-29 11:41:26 +02:00
$ docker-compose stop
2016-11-10 10:19:35 +01:00
$ docker run -it --name gc --rm --volumes-from registry registry:2.5.0 garbage-collect --dry-run /etc/registry/config.yml
2016-06-28 07:47:31 +02:00
```
2016-11-07 14:53:46 +01:00
**NOTE:** The above option "--dry-run" will print the progress without removing any data.
Verify the result of the above test, then use the below commands to perform garbage collection and restart Harbor.
2016-06-30 11:27:37 +02:00
2016-11-07 14:53:46 +01:00
```sh
2016-11-10 10:19:35 +01:00
$ docker run -it --name gc --rm --volumes-from registry registry:2.5.0 garbage-collect /etc/registry/config.yml
2016-11-07 14:53:46 +01:00
$ docker-compose start
```
2016-06-28 07:47:31 +02:00
2016-11-10 10:19:35 +01:00
For more information about GC, please see [GC](https://github.com/docker/docker.github.io/blob/master/registry/garbage-collection.md).