|
1 | 1 | # PouchContainer 入门
|
2 | 2 |
|
3 |
| -文本介绍 PouchContainer 的安装及基本使用,如pull、run,管理等。 |
| 3 | +# 快速入门 |
| 4 | + |
| 5 | +总共提供了两个快速入门,一个用于终端用户,另一个用于开发人员。 |
| 6 | + |
| 7 | +希望使用PouchContainer的终端用户,请阅读[终端用户快速入门](#终端用户快速入门)以安装和探索PouchContainer。 |
| 8 | + |
| 9 | +希望开发PouchContainer的开发人员,请阅读[开发人员快速入门](#开发人员快速入门)以开始开发并参与项目! |
| 10 | + |
| 11 | +## <div id="终端用户快速入门">终端用户快速入门</div> |
| 12 | + |
| 13 | +只需很少的步骤,您就可以在您的机器上自动安装PouchContainer。目前我们支持两种Linux发行版:Ubuntu和CentOS。 |
| 14 | + |
| 15 | +### Ubuntu |
| 16 | + |
| 17 | +要安装PouchContainer,您需要一个Ubuntu 16.04(Xenial LTS)在维护的版本。不支持存档和测试版本。 |
| 18 | + |
| 19 | +PouchContainer与Docker冲突,因此您必须在安装PouchContainer之前卸载Docker。 |
| 20 | + |
| 21 | +**准备工作** |
| 22 | + |
| 23 | +PouchContainer支持LXCFS以提供强隔离,因此您应首先安装LXCFS。默认情况下,LXCFS是被启用的。 |
| 24 | + |
| 25 | +``` bash |
| 26 | +sudo apt-get install lxcfs |
| 27 | +``` |
| 28 | + |
| 29 | +安装下列包以允许'apt'通过HTTPS使用仓库: |
| 30 | + |
| 31 | +``` bash |
| 32 | +sudo apt-get install curl apt-transport-https ca-certificates software-properties-common |
| 33 | +``` |
| 34 | + |
| 35 | +**1. 添加PouchContainer的官方GPG密钥** |
| 36 | + |
| 37 | +``` bash |
| 38 | +curl -fsSL http://mirrors.aliyun.com/opsx/pouch/linux/debian/ [email protected] | sudo apt-key add - |
| 39 | +``` |
| 40 | + |
| 41 | +通过搜索指纹的最后8个字符,验证您现在是否具有指纹 `F443 EDD0 4A58 7E8B F645 9C40 CF68 F84A BE2F 475F`的密钥。 |
| 42 | + |
| 43 | +``` bash |
| 44 | +$ apt-key fingerprint BE2F475F |
| 45 | +pub 4096R/BE2F475F 2018-02-28 |
| 46 | + Key fingerprint = F443 EDD0 4A58 7E8B F645 9C40 CF68 F84A BE2F 475F |
| 47 | +uid opsx-admin <[email protected]> |
| 48 | +``` |
| 49 | + |
| 50 | +**2. 建立PouchContainer仓库** |
| 51 | + |
| 52 | +在新主机上首次安装PouchContainer之前,您需要建立PouchContainer仓库。我们默认启用了`stabel` 仓库,因为您始终需要`stabel` 仓库。要添加 `test` 仓库,请在以下命令行中的单词 `stable` 之后添加单词 `test` 。在此之后,您可以从仓库安装和更新PouchContainer。 |
| 53 | + |
| 54 | +``` bash |
| 55 | +sudo add-apt-repository "deb http://mirrors.aliyun.com/opsx/pouch/linux/debian/ pouch stable" |
| 56 | +``` |
| 57 | + |
| 58 | +**3. 安装PouchContainer** |
| 59 | + |
| 60 | +安装最新版本的PouchContainer。 |
| 61 | + |
| 62 | +``` bash |
| 63 | +# update the apt package index |
| 64 | +sudo apt-get update |
| 65 | +sudo apt-get install pouch |
| 66 | +``` |
| 67 | + |
| 68 | +安装PouchContainer后,将创建 `pouch` 组,但该组中未添加任何用户。 |
| 69 | + |
| 70 | +**4. 启动PouchContainer** |
| 71 | + |
| 72 | +``` bash |
| 73 | +sudo service pouch start |
| 74 | +``` |
| 75 | + |
| 76 | +在此之后,您可以拉取一个镜像并运行PouchContainer容器。 |
| 77 | + |
| 78 | +### CentOS |
| 79 | + |
| 80 | +要安装PouchContainer,您需要一个CentOS 7在维护的版本。不支持存档和测试版本。 |
| 81 | + |
| 82 | +我们已将rpm包放到Aliyun镜像中,您可以使用PouchContainer仓库安装PouchContainer。如果您在一台新主机上第一次安装PouchContainer,则需要建立PouchContainer仓库。然后,您可以从仓库安装和更新PouchContainer。 |
| 83 | + |
| 84 | +**1. 安装yum-utils** |
| 85 | + |
| 86 | +安装所需的包。 yum-utils提供了yum-config-manager的实用工具。 |
| 87 | + |
| 88 | +``` bash |
| 89 | +sudo yum install -y yum-utils |
| 90 | +``` |
| 91 | + |
| 92 | +**2. 建立PouchContainer仓库** |
| 93 | + |
| 94 | +使用以下命令添加PouchContainer仓库。 |
| 95 | + |
| 96 | +``` bash |
| 97 | +sudo yum-config-manager --add-repo http://mirrors.aliyun.com/opsx/opsx-centos7.repo |
| 98 | +sudo yum update |
| 99 | +``` |
| 100 | + |
| 101 | +注意:上述命令设置了 `stable` 仓库,您可以通过以下命令启用 `test` 仓库。 |
| 102 | + |
| 103 | +``` bash |
| 104 | +sudo yum-config-manager --enable pouch-test |
| 105 | +``` |
| 106 | + |
| 107 | +您可以通过运行 `yum-config-manager` 命令和 `--disable` 参数来禁用 `test` 仓库。要重新启用它,请使用 `--enable` 参数。使用以下命令可以禁用 `test` 仓库。 |
| 108 | + |
| 109 | +``` bash |
| 110 | +sudo yum-config-manager --disable pouch-test |
| 111 | +``` |
| 112 | + |
| 113 | +**3. 安装PouchContainer** |
| 114 | + |
| 115 | +运行以下命令以安装最新版本的PouchContainer。如果您是第一次在您的主机上安装PouchContainer,系统将提示您接受GPG密钥,并显示密钥的指纹。 |
| 116 | + |
| 117 | +``` bash |
| 118 | +sudo yum install pouch |
| 119 | +``` |
| 120 | + |
| 121 | +安装PouchContainer后,将创建 `pouch` 组,但该组中未添加任何用户。 |
| 122 | + |
| 123 | +**4. 启动PouchContainer** |
| 124 | + |
| 125 | +``` bash |
| 126 | +sudo systemctl start pouch |
| 127 | +``` |
| 128 | + |
| 129 | +在此之后,您可以拉取一个镜像并运行PouchContainer容器。 |
| 130 | + |
| 131 | +## 卸载pouch |
| 132 | + |
| 133 | +在Ubuntu上卸载 |
| 134 | + |
| 135 | +``` bash |
| 136 | +sudo apt-get purge pouch |
| 137 | +``` |
| 138 | + |
| 139 | +在CentOS上卸载 |
| 140 | + |
| 141 | +``` bash |
| 142 | +sudo yum remove pouch |
| 143 | +``` |
| 144 | + |
| 145 | +运行 `remove` 命令后,您主机上的镜像,容器,存储卷和自定义配置文件不会被自动删除。若要删除所有镜像,容器和存储卷,请执行以下命令: |
| 146 | + |
| 147 | +``` bash |
| 148 | +sudo rm -rf /var/lib/pouch |
| 149 | +``` |
| 150 | + |
| 151 | +## <div id="开发人员快速入门">开发人员快速入门</div> |
| 152 | + |
| 153 | +本指南提供了在裸机服务器或虚拟机上部署PouchContainer的步骤说明。作为开发人员,您需要通过源代码构建和测试PouchContainer二进制文件。要构建被称为"PouchContainer Daemon"的pouchd和被称为"PouchContainer CLI"的pouch,需要安装以下系统依赖项: |
| 154 | + |
| 155 | +* Linux Kernel 3.10+ |
| 156 | +* Go 1.9.0+ |
| 157 | +* containerd: 1.0.3 |
| 158 | +* runc: 1.0.0-rc4 |
| 159 | +* runv: 1.0.0 (option) |
| 160 | + |
| 161 | + |
| 162 | +### 预安装 |
| 163 | + |
| 164 | +由于pouchd是一种容器引擎,而pouch是一个CLI工具,如果您希望通过pouch体验容器的管理能力,还需要几个额外的二进制文件: |
| 165 | + |
| 166 | +* [containerd](https://github.com/containerd/containerd): 行业标准的容器运行时环境; |
| 167 | +* [runc](https://github.com/opencontainers/runc): 用于根据OCI规范生成和运行容器的CLI工具; |
| 168 | +* [runv](https://github.com/hyperhq/runv): 基于监管服务的OCI运行时环境; |
| 169 | + |
| 170 | +以下是安装 `containerd` 和runc的shell脚本: |
| 171 | + |
| 172 | +``` shell |
| 173 | +# install containerd |
| 174 | +$ wget https://github.com/containerd/containerd/releases/download/v1.0.3/containerd-1.0.3.linux-amd64.tar.gz |
| 175 | +$ tar -xzvf containerd-1.0.3.linux-amd64.tar.gz -C /usr/local |
| 176 | +$ |
| 177 | +# install runc |
| 178 | +$ wget https://github.com/opencontainers/runc/releases/download/v1.0.0-rc4/runc.amd64 -P /usr/local/bin |
| 179 | +$ chmod +x /usr/local/bin/runc.amd64 |
| 180 | +$ mv /usr/local/bin/runc.amd64 /usr/local/bin/runc |
| 181 | +``` |
| 182 | + |
| 183 | +### runV安装 |
| 184 | + |
| 185 | +如果您希望额外体验基于监管服务的虚拟化,您需要安装[runV](https://github.com/hyperhq/runv)。 |
| 186 | + |
| 187 | +有关使用runV体验PouchContainer的更多指南,包括runv安装,请参考[PouchContainer run with runv guide](docs/features/pouch_with_runV.md)。 |
| 188 | + |
| 189 | +### PouchContainer的构建和安装 |
| 190 | + |
| 191 | +安装完所有依赖后,您可以构建和安装PouchContainer Daemo和PouchContainer CLI。克隆仓库并检出任意您选择的分支(在以下示例中,检出的是主干分支): |
| 192 | + |
| 193 | +``` shell |
| 194 | +mkdir -p $GOPATH/src/github.com/alibaba/ |
| 195 | +cd $GOPATH/src/github.com/alibaba/; git clone https://github.com/alibaba/pouch.git |
| 196 | +cd pouch; git checkout master |
| 197 | +``` |
| 198 | + |
| 199 | +名为 `build` 的Makefile target将编译当前工作目录中的pouch和pouchd二进制文件。或者您可以执行 `make install` 来构建二进制文件并将它们安装在目标目录中(默认情况下为 `/usr/local/bin` )。 |
| 200 | + |
| 201 | +``` shell |
| 202 | +make install |
| 203 | +``` |
| 204 | + |
| 205 | +### 启动PouchContainer |
| 206 | +安装了所有需要的二进制文件后,您可以通过以下方式启动pouchd: |
| 207 | + |
| 208 | +``` shell |
| 209 | +$ pouchd |
| 210 | +INFO[0000] starting containerd module=containerd revision=773c489c9c1b21a6d78b5c538cd395416ec50f88 version=v1.0.3 |
| 211 | +INFO[0000] setting subreaper... module=containerd |
| 212 | +INFO[0000] loading plugin "io.containerd.content.v1.content"... module=containerd type=io.containerd.content.v1 |
| 213 | +INFO[0000] loading plugin "io.containerd.snapshotter.v1.btrfs"... module=containerd type=io.containerd.snapshotter.v1 |
| 214 | +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 |
| 215 | +INFO[0000] loading plugin "io.containerd.snapshotter.v1.overlayfs"... module=containerd type=io.containerd.snapshotter.v1 |
| 216 | +INFO[0000] loading plugin "io.containerd.metadata.v1.bolt"... module=containerd type=io.containerd.metadata.v1 |
| 217 | +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" |
| 218 | +INFO[0000] loading plugin "io.containerd.differ.v1.walking"... module=containerd type=io.containerd.differ.v1 |
| 219 | +INFO[0000] loading plugin "io.containerd.grpc.v1.containers"... module=containerd type=io.containerd.grpc.v1 |
| 220 | +``` |
| 221 | + |
| 222 | +在pouchd运行之后,您可以通过PouchContainer CLI与pouchd进行交互: |
| 223 | + |
| 224 | +```bash |
| 225 | +$ pouch images |
| 226 | +IMAGE ID IMAGE NAME SIZE |
| 227 | +3e8fa85ddfef docker.io/library/busybox:latest 2699 |
| 228 | +504cf109b492 docker.io/library/redis:alpine 2035 |
| 229 | +``` |
| 230 | + |
| 231 | +## 反馈 |
| 232 | + |
| 233 | +我们希望本指南可以帮助您使用和运行PouchContainer。如果您有任何疑问,请随时通过[ISSUE](https://github.com/alibaba/pouch/issues/new)发送反馈。如果您希望在本指南中为PouchContainer做出贡献,请提交PR。 |
0 commit comments