In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the method of using LXC container in Ubuntu system". In the daily operation, I believe that many people have doubts about the method of using LXC container in Ubuntu system. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "the method of using LXC container in Ubuntu system". Next, please follow the editor to study!
Install LXC under Ubuntu
Use the following command to install LXC's tools in user mode:
The code is as follows:
$sudo apt-get install lxc
Then check whether the current kernel supports LXC. If all results are "enable", the kernel supports:
The code is as follows:
$lxc-checkconfig
After installing the LXC tool, you can see that LXC automatically creates a bridge card (lxcbr0, which can be set in / etc/lxc/default.conf).
When you create a LXC container, its network port is automatically linked to the bridge card, and the container can communicate with the outside world.
Create a LXC container
To create a LXC container in a specified environment (such as Debian Wheezy 64-bit), you need a corresponding LXC template. Fortunately, the tools provided by LXC integrate a complete set of ready-made LXC templates, which you can find in the / usr/share/lxc/templates directory.
The code is as follows:
$ls / usr/share/lxc/templates
A LXC template is essentially a script that creates a container in a specified environment. When you create LXC containers, you need to use them.
For example, if you want to create a new Ubuntu container, use the following command:
The code is as follows:
$sudo lxc-create-n-t ubuntu
By default, this command creates a minimum Ubuntu environment with the same version number as your host, and on my side is the "lively salamander" (version number is 13.10), 64 bits.
Of course, you can also create any version you like, as long as you add a version parameter to the command. For example, create a container for Ubuntu 14.10:
The code is as follows:
$sudo lxc-create-n-t ubuntu-release utopic
This command will download and install the package in the specified environment and create a new container. The whole process takes a few minutes, depending on the type of container, so you may need to wait patiently.
After downloading and installing all the packages, the LXC container image is created, and you can see the default login interface. The container is placed in the / var/lib/lxc/ directory, and the container's root file system is placed in the / var/lib/lxc//rootfs directory.
The packages downloaded during the creation process are saved in the / var/cache/lxc directory, which can save a lot of download time when you want to build another same container.
Look at all the LXC containers on the host with the following command:
The code is as follows:
$sudo lxc-ls-fancy
NAME STATE IPV4 IPV6 AUTOSTART
-
Test-lxc STOPPED-NO
Start the container using the following command. The parameter "- d" opens the container as a background process. If this parameter is not specified, you can turn off the container runner directly on the console interface (LCTT: Ctrl+C key combination).
The code is as follows:
$sudo lxc-start-n-d
After opening the container, check the status:
The code is as follows:
$sudo lxc-ls-fancy
NAME STATE IPV4 IPV6 AUTOSTART
-
Lxc RUNNING 10.0.3.55-NO
The container state is "running" and the container IP is 10.0.3.55.
You can also see that the container's network interface (for example, vethJ06SFL here) is automatically connected to the LXC internal bridge (lxcbr0):
The code is as follows:
$brctl show lxcbr0
Manage LXC containers
Now that we've learned how to create and start a LXC container, let's take a look at how to play with a running container.
Step 1: open the container console:
The code is as follows:
$sudo lxc-console-n
Use the "Crtl+a Q" combination to exit the console.
Stop and delete the container:
The code is as follows:
$sudo lxc-stop-n
$sudo lxc-destroy-n
Copy the container, using the following command:
The code is as follows:
$sudo lxc-stop-n
$sudo lxc-clone-o-n
common problem
This section focuses on the problems you have encountered in using LXC.
The following error was encountered while creating the LXC container:
The code is as follows:
$sudo lxc-create-n test-lxc-t ubuntu
Lxc-create: symbol lookup error: / usr/lib/x86_64-linux-gnu/liblxc.so.1: undefined symbol: cgmanager_get_pid_cgroup_abs_sync
The reason for the error is that you are running the latest LXC, but it depends on an older version of libcgmanager, so the two are not compatible. Upgrade the libcmanager to solve the problem:
The code is as follows:
$sudo apt-get install libcgmanager0
At this point, the study on "how to use LXC containers in Ubuntu systems" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.