# PouchContainer 入门

## PouchContainer 入门

## 快速入门

总共提供了两个快速入门，一个用于终端用户，另一个用于开发人员。

希望使用PouchContainer的终端用户，请阅读[终端用户快速入门](https://gitbook.pouchcontainer.io/getstarted/pages/-LJXoxLrc4FPCJwpi9GF#终端用户快速入门)以安装和探索PouchContainer。

希望开发PouchContainer的开发人员，请阅读[开发人员快速入门](https://gitbook.pouchcontainer.io/getstarted/pages/-LJXoxLrc4FPCJwpi9GF#开发人员快速入门)以开始开发并参与项目！

### 终端用户快速入门

只需很少的步骤，您就可以在您的机器上自动安装PouchContainer。目前我们支持两种Linux发行版：Ubuntu和CentOS。

#### Ubuntu

要安装PouchContainer，您需要一个Ubuntu 16.04（Xenial LTS）在维护的版本。不支持存档和测试版本。

PouchContainer与Docker冲突，因此您必须在安装PouchContainer之前卸载Docker。

**准备工作**

PouchContainer支持LXCFS以提供强隔离，因此您应首先安装LXCFS。默认情况下，LXCFS是被启用的。

```bash
sudo apt-get install lxcfs
```

安装下列包以允许'apt'通过HTTPS使用仓库：

```bash
sudo apt-get install curl apt-transport-https ca-certificates software-properties-common
```

**1. 添加PouchContainer的官方GPG密钥**

```bash
curl -fsSL http://mirrors.aliyun.com/opsx/pouch/linux/debian/opsx@service.alibaba.com.gpg.key | sudo apt-key add -
```

通过搜索指纹的最后8个字符，验证您现在是否具有指纹 `F443 EDD0 4A58 7E8B F645 9C40 CF68 F84A BE2F 475F`的密钥。

```bash
$ apt-key fingerprint BE2F475F
pub   4096R/BE2F475F 2018-02-28
      Key fingerprint = F443 EDD0 4A58 7E8B F645  9C40 CF68 F84A BE2F 475F
uid                  opsx-admin <opsx@service.alibaba.com>
```

**2. 建立PouchContainer仓库**

在新主机上首次安装PouchContainer之前，您需要建立PouchContainer仓库。我们默认启用了`stabel` 仓库，因为您始终需要`stabel` 仓库。要添加 `test` 仓库，请在以下命令行中的单词 `stable` 之后添加单词 `test` 。在此之后，您可以从仓库安装和更新PouchContainer。

```bash
sudo add-apt-repository "deb http://mirrors.aliyun.com/opsx/pouch/linux/debian/ pouch stable"
```

**3. 安装PouchContainer**

安装最新版本的PouchContainer。

```bash
# update the apt package index
sudo apt-get update
sudo apt-get install pouch
```

安装PouchContainer后，将创建 `pouch` 组，但该组中未添加任何用户。

**4. 启动PouchContainer**

```bash
sudo service pouch start
```

在此之后，您可以拉取一个镜像并运行PouchContainer容器。

#### CentOS

要安装PouchContainer，您需要一个CentOS 7在维护的版本。不支持存档和测试版本。

我们已将rpm包放到Aliyun镜像中，您可以使用PouchContainer仓库安装PouchContainer。如果您在一台新主机上第一次安装PouchContainer，则需要建立PouchContainer仓库。然后，您可以从仓库安装和更新PouchContainer。

**1. 安装yum-utils**

安装所需的包。 yum-utils提供了yum-config-manager的实用工具。

```bash
sudo yum install -y yum-utils
```

**2. 建立PouchContainer仓库**

使用以下命令添加PouchContainer仓库。

```bash
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/opsx/opsx-centos7.repo
sudo yum update
```

注意：上述命令设置了 `stable` 仓库，您可以通过以下命令启用 `test` 仓库。

```bash
sudo yum-config-manager --enable pouch-test
```

您可以通过运行 `yum-config-manager` 命令和 `--disable` 参数来禁用 `test` 仓库。要重新启用它，请使用 `--enable` 参数。使用以下命令可以禁用 `test` 仓库。

```bash
sudo yum-config-manager --disable pouch-test
```

**3. 安装PouchContainer**

运行以下命令以安装最新版本的PouchContainer。如果您是第一次在您的主机上安装PouchContainer，系统将提示您接受GPG密钥，并显示密钥的指纹。

```bash
sudo yum install pouch
```

安装PouchContainer后，将创建 `pouch` 组，但该组中未添加任何用户。

**4. 启动PouchContainer**

```bash
sudo systemctl start pouch
```

在此之后，您可以拉取一个镜像并运行PouchContainer容器。

### 卸载pouch

在Ubuntu上卸载

```bash
sudo apt-get purge pouch
```

在CentOS上卸载

```bash
sudo yum remove pouch
```

运行 `remove` 命令后，您主机上的镜像，容器，存储卷和自定义配置文件不会被自动删除。若要删除所有镜像，容器和存储卷，请执行以下命令：

```bash
sudo rm -rf /var/lib/pouch
```

### 开发人员快速入门

本指南提供了在裸机服务器或虚拟机上部署PouchContainer的步骤说明。作为开发人员，您需要通过源代码构建和测试PouchContainer二进制文件。要构建被称为"PouchContainer Daemon"的pouchd和被称为"PouchContainer CLI"的pouch，需要安装以下系统依赖项：

* Linux Kernel 3.10+
* Go 1.9.0+
* containerd: 1.0.3
* runc: 1.0.0-rc4
* runv: 1.0.0 (option)

#### 预安装

由于pouchd是一种容器引擎，而pouch是一个CLI工具，如果您希望通过pouch体验容器的管理能力，还需要几个额外的二进制文件：

* [containerd](https://github.com/containerd/containerd): 行业标准的容器运行时环境；
* [runc](https://github.com/opencontainers/runc): 用于根据OCI规范生成和运行容器的CLI工具；
* [runv](https://github.com/hyperhq/runv): 基于监管服务的OCI运行时环境；

以下是安装 `containerd` 和runc的shell脚本：

```
# install containerd
$ wget https://github.com/containerd/containerd/releases/download/v1.0.3/containerd-1.0.3.linux-amd64.tar.gz
$ tar -xzvf containerd-1.0.3.linux-amd64.tar.gz -C /usr/local
$
# install runc
$ wget https://github.com/opencontainers/runc/releases/download/v1.0.0-rc4/runc.amd64 -P /usr/local/bin
$ chmod +x /usr/local/bin/runc.amd64
$ mv /usr/local/bin/runc.amd64 /usr/local/bin/runc
```

#### runV安装

如果您希望额外体验基于监管服务的虚拟化，您需要安装[runV](https://github.com/hyperhq/runv)。

有关使用runV体验PouchContainer的更多指南，包括runv安装，请参考[PouchContainer run with runv guide](https://github.com/pouchcontainer/gitbook/tree/4d0e9d2bfb74ed163ae4a7ebf293001ebc38bbdc/GetStarted/docs/features/pouch_with_runV.md)。

#### PouchContainer的构建和安装

安装完所有依赖后，您可以构建和安装PouchContainer Daemo和PouchContainer CLI。克隆仓库并检出任意您选择的分支（在以下示例中，检出的是主干分支）：

```
mkdir -p $GOPATH/src/github.com/alibaba/
cd $GOPATH/src/github.com/alibaba/; git clone https://github.com/alibaba/pouch.git
cd pouch; git checkout master
```

名为 `build` 的Makefile target将编译当前工作目录中的pouch和pouchd二进制文件。或者您可以执行 `make install` 来构建二进制文件并将它们安装在目标目录中（默认情况下为 `/usr/local/bin` ）。

```
make install
```

#### 启动PouchContainer

安装了所有需要的二进制文件后，您可以通过以下方式启动pouchd：

```
$ pouchd
INFO[0000] starting containerd                           module=containerd revision=773c489c9c1b21a6d78b5c538cd395416ec50f88 version=v1.0.3
INFO[0000] setting subreaper...                          module=containerd
INFO[0000] loading plugin "io.containerd.content.v1.content"...  module=containerd type=io.containerd.content.v1
INFO[0000] loading plugin "io.containerd.snapshotter.v1.btrfs"...  module=containerd type=io.containerd.snapshotter.v1
WARN[0000] failed to load plugin io.containerd.snapshotter.v1.btrfs  error="path /var/lib/containerd/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter" module=containerd
INFO[0000] loading plugin "io.containerd.snapshotter.v1.overlayfs"...  module=containerd type=io.containerd.snapshotter.v1
INFO[0000] loading plugin "io.containerd.metadata.v1.bolt"...  module=containerd type=io.containerd.metadata.v1
WARN[0000] could not use snapshotter btrfs in metadata plugin  error="path /var/lib/containerd/io.containerd.snapshotter.v1.btrfs must be a btrfs filesystem to be used with the btrfs snapshotter" module="containerd/io.containerd.metadata.v1.bolt"
INFO[0000] loading plugin "io.containerd.differ.v1.walking"...  module=containerd type=io.containerd.differ.v1
INFO[0000] loading plugin "io.containerd.grpc.v1.containers"...  module=containerd type=io.containerd.grpc.v1
```

在pouchd运行之后，您可以通过PouchContainer CLI与pouchd进行交互：

```bash
$ pouch images
IMAGE ID             IMAGE NAME                                               SIZE
3e8fa85ddfef         docker.io/library/busybox:latest                         2699
504cf109b492         docker.io/library/redis:alpine                           2035
```

### 反馈

我们希望本指南可以帮助您使用和运行PouchContainer。如果您有任何疑问，请随时通过[ISSUE](https://github.com/alibaba/pouch/issues/new)发送反馈。如果您希望在本指南中为PouchContainer做出贡献，请提交PR。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.pouchcontainer.io/getstarted/getstartedwithpouchcontainer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
