日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

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

簡單地說,LXD 就是一個提供了 REST API 的 LXC 容器管理器,LXD 最主要的目標就是使用 Linux 容器而不是硬件虛擬化向用戶提供一種接近虛擬機的使用體驗。

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

環(huán)境需求

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

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

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

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

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

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

幾秒鐘之后,執(zhí)行 lxc list 將會展示容器的 IP 地址,這表明已經啟動了 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         |
+-------------+---------+----------------------+----------------------------------------------+------------+-----------+

之后你就可以像使用其他的交互一樣和這個容器進行交互:

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:~#

更新容器

如果你一直關注著 Ubuntu Core 的開發(fā),你應該知道上面的版本已經很老了。這是因為被用作 Ubuntu LXD 鏡像的代碼每隔幾個月才會更新。Ubuntu Core 系統(tǒng)在重啟時會檢查更新并進行自動更新(更新失敗會回退)。

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

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 軟件包

以一個最簡單的例子開始,經典的 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 實例。

如果你想直接通過 git 測試最新版 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.

已經設置過的容器不能回退版本,但是可以在 Ubuntu Core 16 中運行另一個 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,這是一個不錯的方法。對于 snap 包開發(fā)者來說,這也是一個不錯的工具來測試你的 snap 包能否在不同的環(huán)境下正常運行。

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

最后是一個警告,對于測試來說,這些鏡像是足夠的,但是當前并沒有被正式的支持。在不久的將來,官方的 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容器中運行UbuntuCore
分享地址:http://www.dlmjj.cn/article/cdhhpih.html