日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
在LXD容器中運(yùn)行UbuntuCore

簡(jiǎn)單地說,LXD 就是一個(gè)提供了 REST API 的 LXC 容器管理器,LXD 最主要的目標(biāo)就是使用 Linux 容器而不是硬件虛擬化向用戶提供一種接近虛擬機(jī)的使用體驗(yàn)。

創(chuàng)新互聯(lián)是一家專業(yè)提供紫金企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、H5響應(yīng)式網(wǎng)站、小程序制作等業(yè)務(wù)。10年已為紫金眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站建設(shè)公司優(yōu)惠進(jìn)行中。

環(huán)境需求

就 LXD 而言,Ubuntu Core 僅僅相當(dāng)于另一個(gè) Linux 發(fā)行版。也就是說,snapd 需要掛載無特權(quán)的 FUSE 和 AppArmor 命名空間以及軟件棧,像下面這樣:

  1. 一個(gè)新版的使用 Ubuntu 官方內(nèi)核的系統(tǒng)
  2. 一個(gè)新版的 LXD

創(chuàng)建一個(gè) Ubuntu Core 容器

當(dāng)前 Ubuntu Core 鏡像發(fā)布在社區(qū)的鏡像服務(wù)器。你可以像這樣啟動(dòng)一個(gè)新的容器:

stgraber@dakara:~$ lxc launch images:ubuntu-core/16 ubuntu-core
Creating ubuntu-core
Starting ubuntu-core

這個(gè)容器啟動(dòng)需要一點(diǎn)點(diǎn)時(shí)間,它會(huì)先執(zhí)行第一階段的加載程序,加載程序會(huì)確定使用哪一個(gè)鏡像(鏡像是只讀的),并且在系統(tǒng)上設(shè)置一個(gè)可讀層,你不要在這一階段中斷容器執(zhí)行,這個(gè)時(shí)候什么都沒有,所以執(zhí)行l(wèi)xc exec 將會(huì)出錯(cuò)。

幾秒鐘之后,執(zhí)行 lxc list 將會(huì)展示容器的 IP 地址,這表明已經(jīng)啟動(dòng)了 Ubuntu Core:

stgraber@dakara:~$ lxc list
+-------------+---------+----------------------+----------------------------------------------+------------+-----------+
|     NAME    |  STATE  |          IPV4        |                      IPV6                    |    TYPE    | SNAPSHOTS |
+-------------+---------+----------------------+----------------------------------------------+------------+-----------+
| ubuntu-core | RUNNING | 10.90.151.104 (eth0) | 2001:470:b368:b2b5:216:3eff:fee1:296f (eth0) | PERSISTENT | 0         |
+-------------+---------+----------------------+----------------------------------------------+------------+-----------+

之后你就可以像使用其他的交互一樣和這個(gè)容器進(jìn)行交互:

stgraber@dakara:~$ lxc exec ubuntu-core bash
root@ubuntu-core:~# snap list
Name       Version     Rev  Developer  Notes
core       16.04.1     394  canonical  -
pc         16.04-0.8   9    canonical  -
pc-kernel  4.4.0-45-4  37   canonical  -
root@ubuntu-core:~#

更新容器

如果你一直關(guān)注著 Ubuntu Core 的開發(fā),你應(yīng)該知道上面的版本已經(jīng)很老了。這是因?yàn)楸挥米?Ubuntu LXD 鏡像的代碼每隔幾個(gè)月才會(huì)更新。Ubuntu Core 系統(tǒng)在重啟時(shí)會(huì)檢查更新并進(jìn)行自動(dòng)更新(更新失敗會(huì)回退)。

如果你想現(xiàn)在強(qiáng)制更新,你可以這樣做:

stgraber@dakara:~$ lxc exec ubuntu-core bash
root@ubuntu-core:~# snap refresh
pc-kernel (stable) 4.4.0-53-1 from 'canonical' upgraded
core (stable) 16.04.1 from 'canonical' upgraded
root@ubuntu-core:~# snap version
snap 2.17
snapd 2.17
series 16
root@ubuntu-core:~#
然后重啟一下 Ubuntu Core 系統(tǒng),然后看看 snapd 的版本。
root@ubuntu-core:~# reboot
root@ubuntu-core:~#
stgraber@dakara:~$ lxc exec ubuntu-core bash
root@ubuntu-core:~# snap version
snap 2.21
snapd 2.21
series 16
root@ubuntu-core:~#

你也可以像下面這樣查看所有 snapd 的歷史記錄:

stgraber@dakara:~$ lxc exec ubuntu-core snap changes
ID  Status  Spawn                 Ready                 Summary
1   Done    2017-01-31T05:14:38Z  2017-01-31T05:14:44Z  Initialize system state
2   Done    2017-01-31T05:14:40Z  2017-01-31T05:14:45Z  Initialize device
3   Done    2017-01-31T05:21:30Z  2017-01-31T05:22:45Z  Refresh all snaps in the system

安裝 Snap 軟件包

以一個(gè)最簡(jiǎn)單的例子開始,經(jīng)典的 Hello World:

stgraber@dakara:~$ lxc exec ubuntu-core bash
root@ubuntu-core:~# snap install hello-world
hello-world 6.3 from 'canonical' installed
root@ubuntu-core:~# hello-world
Hello World!

接下來讓我們看一些更有用的:

stgraber@dakara:~$ lxc exec ubuntu-core bash
root@ubuntu-core:~# snap install nextcloud
nextcloud 11.0.1snap2 from 'nextcloud' installed

之后通過 HTTP 訪問你的容器就可以看到剛才部署的 Nextcloud 實(shí)例。

如果你想直接通過 git 測(cè)試最新版 LXD,你可以這樣做:

stgraber@dakara:~$ lxc config set ubuntu-core security.nesting true
stgraber@dakara:~$ lxc exec ubuntu-core bash
root@ubuntu-core:~# snap install lxd --edge
lxd (edge) git-c6006fb from 'canonical' installed
root@ubuntu-core:~# lxd init
Name of the storage backend to use (dir or zfs) [default=dir]:
We detected that you are running inside an unprivileged container.
This means that unless you manually configured your host otherwise,
you will not have enough uid and gid to allocate to your containers.
LXD can re-use your container's own allocation to avoid the problem. Doing so makes your nested containers slightly less safe as they could in theory attack their parent container and gain more privileges than they otherwise would. Would you like to have your containers share their parent's allocation (yes/no) [default=yes]?
Would you like LXD to be available over the network (yes/no) [default=no]?
Would you like stale cached images to be updated automatically (yes/no) [default=yes]?
Would you like to create a new network bridge (yes/no) [default=yes]?
What should the new bridge be called [default=lxdbr0]?
What IPv4 address should be used (CIDR subnet notation, “auto” or “none”) [default=auto]?
What IPv6 address should be used (CIDR subnet notation, “auto” or “none”) [default=auto]?
LXD has been successfully configured.

已經(jīng)設(shè)置過的容器不能回退版本,但是可以在 Ubuntu Core 16 中運(yùn)行另一個(gè) Ubuntu Core 16 容器:

root@ubuntu-core:~# lxc launch images:ubuntu-core/16 nested-core
Creating nested-core
Starting nested-core
root@ubuntu-core:~# lxc list
+-------------+---------+---------------------+-----------------------------------------------+------------+-----------+
|    NAME     |  STATE  |         IPV4        |                       IPV6                    |    TYPE    | SNAPSHOTS |
+-------------+---------+---------------------+-----------------------------------------------+------------+-----------+
| nested-core | RUNNING | 10.71.135.21 (eth0) | fd42:2861:5aad:3842:216:3eff:feaf:e6bd (eth0) | PERSISTENT | 0         |
+-------------+---------+---------------------+-----------------------------------------------+------------+-----------+

寫在最后

如果你只是想試用一下 Ubuntu Core,這是一個(gè)不錯(cuò)的方法。對(duì)于 snap 包開發(fā)者來說,這也是一個(gè)不錯(cuò)的工具來測(cè)試你的 snap 包能否在不同的環(huán)境下正常運(yùn)行。

如果你希望你的系統(tǒng)總是最新的,并且整體可復(fù)制,Ubuntu Core 是一個(gè)很不錯(cuò)的方案,不過這也會(huì)帶來一些相應(yīng)的限制,所以可能不太適合你。

最后是一個(gè)警告,對(duì)于測(cè)試來說,這些鏡像是足夠的,但是當(dāng)前并沒有被正式的支持。在不久的將來,官方的 Ubuntu server 可以完整的支持 Ubuntu Core LXD 鏡像。

附錄

  • LXD 主站:https://linuxcontainers.org/lxd
  • Github:https://github.com/lxc/lxd
  • 郵件列表:https://lists.linuxcontainers.org
  • IRC:#lxcontainers on irc.freenode.net
  • 在線試用:https://linuxcontainers.org/lxd/try-it

分享名稱:在LXD容器中運(yùn)行UbuntuCore
標(biāo)題路徑:http://m.5511xx.com/article/cdhhpih.html