Skip to content

Commit

Permalink
Update docs for 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
STARRY-S committed Apr 8, 2024
1 parent 8f50774 commit 8c2921c
Show file tree
Hide file tree
Showing 53 changed files with 3,167 additions and 31 deletions.
4 changes: 4 additions & 0 deletions i18n/zh/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,5 +320,9 @@
"theme.unlistedContent.message": {
"message": "此页面未列出。搜索引擎不会对其索引,只有拥有直接链接的用户才能访问。",
"description": "The unlisted content banner message"
},
"theme.docs.DocCard.categoryDescription.plurals": {
"message": "{count} 个项目",
"description": "The default description for a category card in the generated index about how many items this category includes"
}
}
8 changes: 8 additions & 0 deletions i18n/zh/docusaurus-plugin-content-docs/version-v1.7.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,13 @@
"sidebar.docs.category.开发调试": {
"message": "开发调试",
"description": "The label for category 开发调试 in sidebar docs"
},
"sidebar.docs.category.Archive": {
"message": "Archive",
"description": "The label for category Archive in sidebar docs"
},
"sidebar.docs.category.最佳实践": {
"message": "最佳实践",
"description": "The label for category 最佳实践 in sidebar docs"
}
}
46 changes: 46 additions & 0 deletions i18n/zh/docusaurus-plugin-content-docs/version-v1.8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"version.label": {
"message": "v1.8 (preview)",
"description": "The label for version v1.8"
},
"sidebar.docs.category.Mirror": {
"message": "Mirror",
"description": "The label for category Mirror in sidebar docs"
},
"sidebar.docs.category.Save": {
"message": "Save",
"description": "The label for category Save in sidebar docs"
},
"sidebar.docs.category.Load": {
"message": "Load",
"description": "The label for category Load in sidebar docs"
},
"sidebar.docs.category.Sync": {
"message": "Sync",
"description": "The label for category Sync in sidebar docs"
},
"sidebar.docs.category.Sign images": {
"message": "Sign images",
"description": "The label for category Sign images in sidebar docs"
},
"sidebar.docs.category.Scan images": {
"message": "Scan images",
"description": "The label for category Scan images in sidebar docs"
},
"sidebar.docs.category.Archive": {
"message": "Archive",
"description": "The label for category Archive in sidebar docs"
},
"sidebar.docs.category.Advanced Usage": {
"message": "Advanced Usage",
"description": "The label for category Advanced Usage in sidebar docs"
},
"sidebar.docs.category.Development": {
"message": "Development",
"description": "The label for category Development in sidebar docs"
},
"sidebar.docs.category.Best Practice": {
"message": "Best Practice",
"description": "The label for category Best Practice in sidebar docs"
}
}
72 changes: 72 additions & 0 deletions i18n/zh/docusaurus-plugin-content-docs/version-v1.8/01-install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: 安装指南
---

您可使用 Hangar Docker 镜像在容器中运行 Hangar。除此之外您可在系统中安装 Hangar 可执行文件。

## Hangar Docker 镜像

- 使用 `docker` 运行 Hangar 容器镜像:

```sh
# Docker
docker pull cnrancher/hangar:latest

docker run -it -v $(pwd):/hangar cnrancher/hangar:latest
```

- 使用 `podman` 运行 Hangar 容器镜像:

```sh
# Podman
podman pull docker.io/cnrancher/hangar:latest
podman run -it -v $(pwd):/hangar cnrancher/hangar:latest
```

有关 Hangar Docker 镜像的更多使用介绍,请参考 [Hangar Docker 镜像](/docs/v1.8/docker-image) 页面。

## 安装到 Linux 系统

### Arch Linux

您可在 Arch Linux [AUR](https://aur.archlinux.org/packages/hangar) 仓库获取 `PKGBUILD`,在本地编译并安装 Hangar。

- 使用 [yay](https://github.com/Jguer/yay) AUR Helper 安装 Hangar:

```sh
# 从最新的 stable release tag 构建并安装 Hangar。
yay hangar
# 从最新的上游 git main 分支源码构建并安装 Hangar。
yay hangar-git
```

- 除此之外,您可以添加 [Open Build Service](https://download.opensuse.org/repositories/home:/StarryWang/Arch/x86_64/) 仓库以安装预构建的 Hangar 安装包。

1. 编辑 `/etc/pacman.conf` 添加自定义软件源:
```txt title="/etc/pacman.conf"
[home_StarryWang_Arch]
SigLevel = Never
Server = https://download.opensuse.org/repositories/home:/StarryWang/Arch/$arch
```
1. 安装 Hangar:
```sh
sudo pacman -Sy
sudo pacman -S hangar
```

### openSUSE

Hangar 可在 [Open Build Service](https://build.opensuse.org/package/show/home:StarryWang/Hangar) 获取。

```sh
# openSUSE Tumbleweed
sudo zypper ar https://download.opensuse.org/repositories/home:StarryWang/openSUSE_Tumbleweed/home:StarryWang.repo
sudo zypper ref
sudo zypper in hangar
```

## 从源代码中构建 Hangar

参考 [编译 Hangar](/docs/v1.8/dev/build) 页面,手动构建 Hangar 可执行文件并安装到系统中。
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: "Login & Logout"
---

您需要在执行拷贝容器镜像操作之前对 *源镜像仓库**目标镜像仓库* 执行 `hangar login`

## 使用方法

```txt title="hangar login --help"
Login to registry server
Usage:
hangar login registry-url [flags]
Examples:
hangar login docker.io
Flags:
--authfile string path of the authentication file. Use REGISTRY_AUTH_FILE environment variable to override
--cert-dir string use certificates at the specified path to access the registry
--get-login Return the current login user for the registry
-h, --help help for login
-p, --password string Password for registry
--password-stdin Take the password from stdin
--retry-times int the number of times to possibly retry (default 3)
--timeout duration login timeout
--tls-verify require HTTPS and verify certificates
-u, --username string Username for registry
-v, --verbose Write more detailed information to stdout
Global Flags:
--debug enable debug output
--insecure-policy run Hangar without policy check
```

## 例子

```bash title="Login to docker hub"
hangar login "docker.io"
```

若使用自签名 HTTPS 证书或 HTTP 镜像仓库,可使用 `--tls-verify=false` 参数。

```bash
hangar login "127.0.0.1:5000" --tls-verify=false
```

:::note

Hangar 会在执行 `mirror/load` 命令时自动检测 *目标镜像仓库* 是否已登录。
但不会检测 *源镜像仓库* 是否已经登录。

因此若 *源镜像仓库* 中存储的镜像为私有镜像,请手动对其执行 `hangar login`

:::

----

使用 `hangar logout` 以移除存储的镜像仓库登录凭证信息。

```bash title="Logout from docker hub"
hangar logout "docker.io"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
title: "Mirror 命令"
---

`hangar mirror` 命令用于在镜像仓库服务器之间批量拷贝容器镜像。Hangar 允许您指定需要拷贝的容器镜像架构 & 平台参数,启用多线程并发拷贝容器镜像。

## 快速上手

使用以下命令在镜像仓库服务器之间多线程的批量拷贝容器镜像:

1. 准备一份样例镜像列表文件。

```txt title="example_image_list.txt"
cnrancher/hangar:latest
cnrancher/hangar:v1.8.0
# Add more images here...
```
> Hangar `mirror` 命令支持两种镜像列表格式,本例中的镜像列表为 `Default` 格式,请参考 [镜像列表格式](/docs/v1.8/mirror/image-list-format) 页面获取镜像列表格式的详细定义。
1. 执行以下命令,将镜像列表中的 **amd64 & arm64, linux** 容器镜像从 *源镜像仓库* 拷贝至 *目标镜像仓库* 中。
```bash
#!/bin/bash
hangar mirror \
--file="example_image_list.txt" \
--source=SOURCE_REGISTRY_URL \
--destination=DESTINATION_REGISTRY_URL \
--arch=amd64,arm64 \
--os=linux \
--jobs=4
```
1. 使用 [Inspect](/docs/v1.8/advanced/inspect) 命令,查看已拷贝的镜像 Manifest。
```bash
hangar inspect --raw docker://DESTINATION_REGISTRY_URL/cnrancher/hangar:latest
```
## 镜像列表格式
`hangar mirror` 支持两种不同的镜像列表格式,请参考 [镜像列表格式](/docs/v1.8/mirror/image-list-format) 页面获取镜像列表格式的详细定义。
## 使用方法
```txt title="hangar mirror --help"
Mirror images between registry servers
Usage:
hangar mirror -f IMAGE_LIST.txt -d DESTINATION_REGISTRY [flags]
hangar mirror [command]
Examples:
# Mirror images from SOURCE REGISTRY to DESTINATION REGISTRY.
hangar mirror \
--file IMAGE_LIST.txt \
--source SOURCE_REGISTRY \
--destination DESTINATION_REGISTRY \
--arch amd64,arm64 \
--os linux
Available Commands:
validate Ensure the images were mirrored correctly
Flags:
-a, --arch strings architecture list of images (default [amd64,arm64])
-d, --destination string specify the destination image registry
--destination-project string override all destination image projects
-o, --failed string file name of the mirror failed image list (default "mirror-failed.txt")
-f, --file string image list file
-h, --help help for mirror
-j, --jobs int worker number, copy images parallelly (1-20) (default 1)
--os strings OS list of images (default [linux])
--skip-login skip check the destination registry is logged in (used in shell script)
-s, --source string override the source registry in image list
--source-project string override all source image projects
--timeout duration timeout when mirror each images (default 10m0s)
--tls-verify require HTTPS and verify certificates
Global Flags:
--debug enable debug output
--insecure-policy run Hangar without policy check
Use "hangar mirror [command] --help" for more information about a command.
```

## Mirror 镜像时自定义 Project

Hangar 的 `mirror` 命令提供一些高级参数,可以用于自定义 *源镜像**目标镜像* 的 Project(Namespace)。

您可使用 `--source-project` 参数,自定义所有 *源镜像* 的 Project,并使用 `--destination-project` 参数,自定义所有 *目标镜像* 的 Project。

以下是一个例子:

- 本例中使用 `Default` 格式的镜像列表,包含了一些 Docker Hub 镜像,这些镜像的 Project 不一致(`library``cnrancher`)。

```txt title="example.txt"
docker.io/library/nginx:latest
docker.io/cnrancher/hangar:latest
```
- 使用 `--destination-project` 参数,将这些镜像拷贝至另一个 Docker Hub 用户。
```shell-session
$ hangar mirror -f "example.txt" --destination-project="USERNAME"
[17:00:00] [INFO] [IMG:1] Copying [docker.io/library/nginx:latest] => [docker.io/USERNAME/nginx:latest]
[17:00:00] [INFO] [IMG:2] Copying [docker.io/cnrancher/hangar:latest] => [docker.io/USERNAME/hangar:latest]
......
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: "Mirror Validate 命令"
---

`hangar mirror validate` 命令用于校验 Mirror 过的镜像是否拷贝正确。

## 快速上手

在执行完 [mirror](/docs/v1.8/mirror/mirror#快速上手) 命令后,使用下方命令校验已拷贝的镜像:

```bash
#!/bin/bash

hangar mirror validate \
--file="example_image_list.txt" \
--source=SOURCE_REGISTRY_URL \
--destination=DESTINATION_REGISTRY_URL \
--arch=amd64,arm64 \
--os=linux \
--jobs=4
```

## 使用方法

```txt title="hangar mirror validate --help"
Ensure the images were mirrored correctly
Usage:
hangar mirror validate -f IMAGE_LIST.txt -d DESTINATION_REGISTRY [flags]
Examples:
hangar mirror validate \
--file IMAGE_LIST.txt \
--source SOURCE_REGISTRY \
--destination DESTINATION_REGISTRY \
--arch amd64,arm64 \
--os linux
Flags:
-h, --help help for validate
Global Flags:
-a, --arch strings architecture list of images (default [amd64,arm64])
--debug enable debug output
-d, --destination string specify the destination image registry
--destination-project string override all destination image projects
-o, --failed string file name of the mirror failed image list (default "mirror-failed.txt")
-f, --file string image list file
--insecure-policy run Hangar without policy check
-j, --jobs int worker number,copy images parallelly (1-20) (default 1)
--os strings OS list of images (default [linux])
--skip-login skip check the destination registry is logged in (used in shell script)
-s, --source string override the source registry in image list
--source-project string override all source image projects
--timeout duration timeout when mirror each images (default 10m0s)
--tls-verify require HTTPS and verify certificates
```
Loading

0 comments on commit 8c2921c

Please sign in to comment.