translated (#6296)

* 2017-11-21

2017-11-21

* 2017-11-21 22:27

* 2017-11-21 23:12

* translated

translated
This commit is contained in:
aiwhj 2017-11-22 17:48:14 +08:00 committed by Fuliang.Li
parent a8d4a05f9b
commit 410e619557

View File

@ -1,6 +1,5 @@
#Translating by aiwhj
Ubuntu Core in LXD containers
使用 LXD 容器运行 Ubuntu Core
============================================================
@ -8,28 +7,28 @@ Ubuntu Core in LXD containers
![LXD logo](https://linuxcontainers.org/static/img/containers.png)
### Whats Ubuntu Core?
### Ubuntu Core 是什么?
Ubuntu Core is a version of Ubuntu thats fully transactional and entirely based on snap packages.
Ubuntu Core 完全基于 snap 包构建,以及完全事务化的 Ubuntu 版本。
Most of the system is read-only. All installed applications come from snap packages and all updates are done using transactions. Meaning that should anything go wrong at any point during a package or system update, the system will be able to revert to the previous state and report the failure.
系统大部分是只读的,所有已安装的包都是 snap 包,完全使用事务化更新。这意味着不管在系统更新还是安装软件的时候遇到问题,整个系统都可以回退到之前的状态并且记录这个错误。
The current release of Ubuntu Core is called series 16 and was released in November 2016.
最新版是在 2016 年 11 月发布的 Ubuntu Core 16。
Note that on Ubuntu Core systems, only snap packages using confinement can be installed (no “classic” snaps) and that a good number of snaps will not fully work in this environment or will require some manual intervention (creating user and groups, …). Ubuntu Core gets improved on a weekly basis as new releases of snapd and the “core” snap are put out.
注意Ubuntu Core 限制只能够安装 snap 包(非 “传统” 包),并且有相当数量的 snap 包在当前环境下不能正常运行,或者需要人工干预(创建用户和用户组等)才能正常运行。由于新版的 “core” snap 包被发布Ubuntu Core 每周都会得到改进。
### Requirements
### 环境需求
As far as LXD is concerned, Ubuntu Core is just another Linux distribution. That being said, snapd does require unprivileged FUSE mounts and AppArmor namespacing and stacking, so you will need the following:
就 LXD 而言Ubuntu Core 仅仅相当于另一个 Linux 发行版。也就是说snapd 需要挂载无特权的 FUSE 和 AppArmor 命名空间以及堆栈,像下面这样:
* An up to date Ubuntu system using the official Ubuntu kernel
* 一个新版传统内核的 Ubuntu 系统
* An up to date version of LXD
* 一个新版的 LXD
### Creating an Ubuntu Core container
### 创建一个 Ubuntu Core 容器
The Ubuntu Core images are currently published on the community image server.
You can launch a new container with:
当前 Ubuntu Core 镜像发布在社区的镜像服务器。
你可以像这样启动一个新的容器:
```
stgraber@dakara:~$ lxc launch images:ubuntu-core/16 ubuntu-core
@ -37,9 +36,9 @@ Creating ubuntu-core
Starting ubuntu-core
```
The container will take a few seconds to start, first executing a first stage loader that determines what read-only image to use and setup the writable layers. You dont want to interrupt the container in that stage and “lxc exec” will likely just fail as pretty much nothing is available at that point.
这个容器启动需要一点点时间,会先执行第一阶段的加载程序,加载程序会确定使用哪一个镜像(镜像是只读的),并且在系统上设置一个可读层,你不想在这一阶段中断容器,这个时候什么都没有,所以执行 “lxc exec”将会出错。
Seconds later, “lxc list” will show the container IP address, indicating that its booted into Ubuntu Core:
几秒钟之后,执行 “lxc list” 将会展示容器的 IP 地址,这表明已经启动了 Ubuntu Core
```
stgraber@dakara:~$ lxc list
@ -50,7 +49,7 @@ stgraber@dakara:~$ lxc list
+-------------+---------+----------------------+----------------------------------------------+------------+-----------+
```
You can then interact with that container the same way you would any other:
之后你就可以像使用其他的交互一样和这个容器进行交互:
```
stgraber@dakara:~$ lxc exec ubuntu-core bash
@ -62,11 +61,11 @@ pc-kernel 4.4.0-45-4 37 canonical -
root@ubuntu-core:~#
```
### Updating the container
### 更新容器
If youve been tracking the development of Ubuntu Core, youll know that those versions above are pretty old. Thats because the disk images that are used as the source for the Ubuntu Core LXD images are only refreshed every few months. Ubuntu Core systems will automatically update once a day and then automatically reboot to boot onto the new version (and revert if this fails).
如果你一直关注着 Ubuntu Core 的开发,你应该知道上面的版本已经很老了。这是因为被用作 Ubuntu LXD 镜像的代码每隔几个月就会更新。Ubuntu Core 系统在重启时会检查更新并进行自动更新(更新失败会回退)。
If you want to immediately force an update, you can do it with:
如果你想现在强制更新,你可以这样做:
```
stgraber@dakara:~$ lxc exec ubuntu-core bash
@ -80,7 +79,7 @@ series 16
root@ubuntu-core:~#
```
And then reboot the system and check the snapd version again:
然后重启一下 Ubuntu Core 系统然后看看 snapd 的版本。
```
root@ubuntu-core:~# reboot
@ -94,7 +93,7 @@ series 16
root@ubuntu-core:~#
```
You can get an history of all snapd interactions with
你也可以像下面这样查看所有 snapd 的历史记录
```
stgraber@dakara:~$ lxc exec ubuntu-core snap changes
@ -104,9 +103,9 @@ ID Status Spawn Ready Summary
3 Done 2017-01-31T05:21:30Z 2017-01-31T05:22:45Z Refresh all snaps in the system
```
### Installing some snaps
### 安装 Snap 软件包
Lets start with the simplest snaps of all, the good old Hello World:
以一个最简单的例子开始,经典的 Hello World
```
stgraber@dakara:~$ lxc exec ubuntu-core bash
@ -116,7 +115,7 @@ root@ubuntu-core:~# hello-world
Hello World!
```
And then move on to something a bit more useful:
接下来让我们看一些更有用的:
```
stgraber@dakara:~$ lxc exec ubuntu-core bash
@ -124,9 +123,9 @@ root@ubuntu-core:~# snap install nextcloud
nextcloud 11.0.1snap2 from 'nextcloud' installed
```
Then hit your container over HTTP and youll get to your newly deployed Nextcloud instance.
之后通过 HTTP 访问你的容器就可以看到刚才部署的 Nextcloud 实例。
If you feel like testing the latest LXD straight from git, you can do so with:
如果你想直接通过 git 测试最新版 LXD你可以这样做
```
stgraber@dakara:~$ lxc config set ubuntu-core security.nesting true
@ -155,7 +154,7 @@ What IPv6 address should be used (CIDR subnet notation, “auto” or “none”
LXD has been successfully configured.
```
And because container inception never gets old, lets run Ubuntu Core 16 inside Ubuntu Core 16:
已经设置过的容器不能回退版本,但是可以在容器中运行另一个容器
```
root@ubuntu-core:~# lxc launch images:ubuntu-core/16 nested-core
@ -169,27 +168,28 @@ root@ubuntu-core:~# lxc list
+-------------+---------+---------------------+-----------------------------------------------+------------+-----------+
```
### Conclusion
### 写在最后
If you ever wanted to try Ubuntu Core, this is a great way to do it. Its also a great tool for snap authors to make sure their snap is fully self-contained and will work in all environments.
这是一个不错的方法,当你只是想试用一下 Ubuntu Core。对于 snap 包开发者来说,这也是一个不错的工具来测试你的 snap 包能否在不同的环境下正常运行。
Ubuntu Core is a great fit for environments where you want to ensure that your system is always up to date and is entirely reproducible. This does come with a number of constraints that may or may not work for you.
如果你希望你的系统总是最新并且可以很轻易的重置Ubuntu Core 是一个很不错的方案,不过这也会带来一些相应的限制,所以可能不太适合你。
And lastly, a word of warning. Those images are considered as good enough for testing, but arent officially supported at this point. We are working towards getting fully supported Ubuntu Core LXD images on the official Ubuntu image server in the near future.
最后是一个警告,对于测试来说,这些镜像是足够的,但是当前并没有被正式的支持。在不久的将来,官方的 Ubuntu server 可以完整的支持 Ubuntu Core LXD 镜像。
### Extra information
### 附录
The main LXD website is at: [https://linuxcontainers.org/lxd][2] Development happens on Github at: [https://github.com/lxc/lxd][3]
Mailing-list support happens on: [https://lists.linuxcontainers.org][4]
IRC support happens in: #lxcontainers on irc.freenode.net
Try LXD online: [https://linuxcontainers.org/lxd/try-it][5]
LXD 主站:[https://linuxcontainers.org/lxd][2]
Github[https://github.com/lxc/lxd][3]
邮件列表:[https://lists.linuxcontainers.org][4]
IRC#lxcontainers on irc.freenode.net
在线试用:[https://linuxcontainers.org/lxd/try-it][5]
--------------------------------------------------------------------------------
via: https://insights.ubuntu.com/2017/02/27/ubuntu-core-in-lxd-containers/
来自: https://insights.ubuntu.com/2017/02/27/ubuntu-core-in-lxd-containers/
作者:[Stéphane Graber ][a]
译者:[译者ID](https://github.com/译者ID)
译者:[aiwhj](https://github.com/aiwhj)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出