In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to run Ubuntu Core in a LXD container". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to run Ubuntu Core in a LXD container.
LXD is a LXC container manager that provides REST API. The main goal of LXD is to use Linux containers rather than hardware virtualization to provide users with a virtual machine-like experience.
Environmental demand
As far as LXD is concerned, Ubuntu Core is just another Linux distribution. That is, snapd needs to mount the unprivileged FUSE and AppArmor namespaces as well as the software stack, as follows:
A new version of the system using the official Ubuntu kernel. A new version of LXD creates a Ubuntu Core container.
The current Ubuntu Core image is published on the community's image server. You can start a new container like this:
Stgraber@dakara:~$ lxc launch images:ubuntu-core/16 ubuntu-coreCreating ubuntu-coreStarting ubuntu-core
This container takes a little time to start, it will first execute the first phase of the loader, the loader will determine which image to use (the image is read-only), and set up a readable layer on the system, you do not interrupt container execution at this stage, there is nothing at this time, so executing lxc exec will make an error.
After a few seconds, executing lxc list will display the IP address of the container, indicating that Ubuntu Core has been started:
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 | +-- -+
You can then interact with this container like any other interaction:
Stgraber@dakara:~$ lxc exec ubuntu-core bashroot@ubuntu-core:~# snap listName Version Rev Developer Notescore 16.04.1 394 canonical-pc 16.04-0.89 canonical-pc-kernel 4.4.0-45-4 37 canonical-root@ubuntu-core:~# update container
If you have been following the development of Ubuntu Core, you should know that the above version is very old. This is because the code used as a Ubuntu LXD mirror is updated every few months. When the Ubuntu Core system restarts, it checks for updates and automatically updates them (if the update fails, it will fall back).
If you want to force updates now, you can do this:
Stgraber@dakara:~$ lxc exec ubuntu-core bashroot@ubuntu-core:~# snap refreshpc-kernel (stable) 4.4.0-53-1 from 'canonical' upgradedcore (stable) 16.04.1 from' canonical' upgradedroot@ubuntu-core:~# snap versionsnap 2.17snapd 2.17series 16root@ubuntu-core:~# then restart the Ubuntu Core system and see the version of snapd. Root@ubuntu-core:~# rebootroot@ubuntu-core:~#stgraber@dakara:~$ lxc exec ubuntu-core bashroot@ubuntu-core:~# snap versionsnap 2.21snapd 2.21series 16root@ubuntu-core:~#
You can also view the history of all snapd as follows:
Stgraber@dakara:~$ lxc exec ubuntu-core snap changesID Status Spawn Ready Summary1 Done 2017-01-31T05:14:38Z 2017-01-31T05:14:44Z Initialize system state2 Done 2017-01-31T05:14:40Z 2017-01-31T05:14:45Z Initialize device3 Done 2017-01-31T05:21:30Z 2017-01-31T05:22:45Z Refresh all snaps in the system install Snap package
Start with the simplest example, the classic Hello World:
Stgraber@dakara:~$ lxc exec ubuntu-core bashroot@ubuntu-core:~# snap install hello-worldhello-world 6.3from 'canonical' installedroot@ubuntu-core:~# hello-worldHello World!
Let's take a look at something more useful:
Stgraber@dakara:~$ lxc exec ubuntu-core bashroot@ubuntu-core:~# snap install nextcloudnextcloud 11.0.1snap2 from 'nextcloud' installed
Then you can see the Nextcloud instance you just deployed by accessing your container through HTTP.
If you want to pass the git test directly on the latest version of LXD, you can do this:
Stgraber@dakara:~$ lxc config set ubuntu-core security.nesting truestgraber@dakara:~$ lxc exec ubuntu-core bashroot@ubuntu-core:~# snap install lxd-- edgelxd (edge) git-c6006fb from 'canonical' installedroot@ubuntu-core:~# lxd initName 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 couldin theory attack their parent container and gain more privileges thanthey 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.
A container that has been set up cannot roll back the version, but you can run another Ubuntu Core 16 container in Ubuntu Core 16:
Root@ubuntu-core:~# lxc launch images:ubuntu-core/16 nested-coreCreating nested-coreStarting nested-coreroot@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 | | +-- + to this point | I believe you have a better understanding of "how to run Ubuntu Core in a LXD container", so you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.