国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
LXD Features
What is LXC?
LXC Features
Requirements
Step 1: Set SELinux to Permissive Mode
Step 2: Install EPEL Repository
Step 3: Add the Kernel Parameters
Step 4: Install and Enable Snap
Step 5: Install LXD Containerization Manager
Step 6: Initializing LXD Environment
Step 7: Listing Prebuilt LXC Container Images
Step 8: Launching LXC Containers
Step 9: Gain Shell Access to an LXC Container
Step 10: Pull / Push a File(s) to an LXC Container
Step 11: Stop / Start / Restart and Delete LXC Containers
Step 12: Get Help on LXC Command-line Options
Conclusion
Home System Tutorial LINUX Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Jul 05, 2025 am 09:25 AM

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines.

It provides images for an inordinate number of Linux distributions with support for a wide selection of storage backends and network types. It also provides the option of installing the images on an individual PC/laptop and even on a cloud instance.

LXD allows you to manage containers and VMs using three ways. You can leverage the lxc client or command-line tool, a REST API, or even third-party integrations.

LXD Features

Notable LXD features include:

  • LXD is image-based with images for a wide selection of Linux distributions.
  • It is built with security as a top priority.
  • It provides a REST API and lxc command-line tool to interact with containers.
  • It provides support for a wide range of storage backends, storage volumes, and storage pools.
  • Network management is through the creation of bridge networks and cross-host tunnels.
  • Advanced control of resources such as CPU, RAM, disk usage, block I/O, and kernel resources.
  • Flexible and scalable – You can deploy containers on your PC and configure a cluster that can aggregate thousands of containers on various nodes.

What is LXC?

Not to be confused with the lxc command-line client tool provided by LXD, LXC (Linux Container) is a popular OS-level virtualization technology that uses a powerful API and other tools to enable users to seamlessly create and manage containers and virtual machines in a single host. It comprises templates, tools language, and library bindings.

LXC Features

LXC leverages the following kernel features to handle processes:

  • Kernel namespaces: pid, mount, uts network, and user.
  • CGroups (control groups).
  • Chroots – Using pivot_root.
  • Seccomp policies.
  • SELinux and Apparmor profiles.

Linuxcontainers.org is the umbrella project behind both LXD and LXC. Its objective is to offer a distro and vendor-neutral platform for Linux container technologies.

With that introduction out of the way, we will now demonstrate how to create and manage LXC containers on RHEL-based Linux distributions such as CentOS, Rocky Linux, and AlmaLinux.

Requirements

A working Linux operating system with minimal installation:

  • Installation of RHEL Linux
  • Installation of CentOS Linux
  • Installation of Rocky Linux
  • Installation of AlmaLinux

Step 1: Set SELinux to Permissive Mode

Right off the bat, we will begin by configuring SELinux and setting it to permissive. But before we do so, let’s update the system packages as follows:

$ sudo dnf update

To set SELinux to permissive, execute the command:

$ sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

For this to take effect, reboot your server.

$ sudo reboot

And confirm the status of SELinux.

$ getenforce

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Step 2: Install EPEL Repository

EPEL is a repository from the Fedora Project that provides a set of high-quality packages for RedHat Enterprise Linux and other RHEL-based distributions.

$ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
OR
$ sudo yum install epel-release

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Step 3: Add the Kernel Parameters

Before we install LXD, some additional parameters are required. Therefore switch to root user:

$ su -

And add the parameters as follows.

$ grubby --args="user_namespace.enable=1" --update-kernel="$(grubby --default-kernel)"
$ grubby --args="namespace.unpriv_enable=1" --update-kernel="$(grubby --default-kernel)"
$ echo "user.max_user_namespaces=3883" | sudo tee -a /etc/sysctl.d/99-userns.conf

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Once the parameters are in place, then proceed and enable Snap.

Step 4: Install and Enable Snap

The simplest way to install LXD on RHEL 8 is to install it as a snap package. But first, let us install snap as follows.

$ sudo dnf install snapd

This will install snapd daemon or service alongside other Python dependencies as shown.

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

With snap installed, proceed and enable the main snap communication socket.

$ sudo systemctl enable --now snapd.socket

In addition, enable classic support by creating a symlink from /var/lib/snapd/snap to /snap.

$ sudo ln -s /var/lib/snapd/snap  /snap

To update the snap paths, restart your system.

$ sudo reboot

Step 5: Install LXD Containerization Manager

There are two ways of installing LXD from a snap. You can install the latest version of LXD as shown.

$ sudo snap install —-classic lxd

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Alternatively, you can install the latest stable LTS version as follows:

$ sudo snap install lxd --channel=4.0/stable

To be able to execute lxc commands without switching to sudo user, add the currently logged-in user to the lxd group.

$ sudo usermod -aG lxd $USER

Verify that the user has been added to the lxd group by listing all the groups the user belongs to.

$ groups tecmint

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Next, run the newgrp command as follows.

$ newgrp lxd

The command changes the current group ID during a login session. It sets the current group ID to the named group which is lxd.

Step 6: Initializing LXD Environment

Before we begin creating and managing LXD containers, we need to initialize the LXD environment by running the command.

$ lxc init

What follows is a series of prompts that will allow you to set up your environment. The defaults will work just fine, but feel free to specify your own preferences.

We have created a storage pool called tec-pool with the lvm option as backend.

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

To verify the LXD environment you have just configured, there are a number of commands you can use. For example, to display the default LXD profile execute:

$ lxc profile show default

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

To display the network adapters and the IPv4 and IPv6 addresses, run:

$ lxc network list

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

You can further narrow it and display finer information about the lxdbr0 interface as follows.

$ lxc network show lxdbr0

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

You can also verify the storage pool.

$ lxc storage list

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

You can further get intricate details about the storage pool.

$ lxc storage show tec-pool

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

To list running lxc containers, run the command:

$ lxc list

At the moment, we do not have any running containers yet. So you will get an empty table with only the column labels.

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Step 7: Listing Prebuilt LXC Container Images

Just like Docker, the LXC platform provides a repository of pre-built images that you can create containers from. To list all the prebuilt images for all operating systems including virtual machines, run the command:

$ lxc image list images: 

This populates a huge list of container images and virtual machines for all the operating systems. To narrow down to a specific Linux distribution, use the syntax:

$ lxc image list images: grep -i os-type

For example, to search for available images for Rocky Linux, run the command:

$ lxc image list images: grep -i rocky

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

If you are searching for Debian images, run the command:

$ lxc image list images: grep -i debian

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Step 8: Launching LXC Containers

To launch lxc containers, use the syntax:

$ lxc launch images:{distro}/{version}/{arch} {container-name-here}

Here, we will launch 2 containers: tec-container1 from Debian 10 and tec-container2 from Rocky Linux 8.

$ lxc launch images:debian/10/amd64 tec-container1
$ lxc launch images:rockylinux/8/amd64 tec-container2 

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

To list the lxc containers, execute the command:

$ lxc list

The output displays a host of information about the containers. This includes the name of the containers, the state – whether running or stopped – IPv4 and IPv6 addresses, type (whether a container or virtual machine), and a number of snapshots.

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

To list running containers only, run the command:

$ lxc list | grep -i running

Likewise, for stopped containers, execute:

$ lxc list | grep -i stopped

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

You can probe for a container’s information and metrics such as running processes, CPU & memory utilization, and bandwidth to mention a few using the command:

$ lxc info tec-container1 

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Step 9: Gain Shell Access to an LXC Container

You can gain bash access to a container using the syntax:

$ lxc exec container-name  name-of-the-shell

To gain shell access to tec-container1, we will run the command:

$ lxc exec tec-container1 bash

Once you have gained shell access, you can start interacting with the container as a root user by running common shell commands including updating the system as shown:

$ apt update

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

To exit from the container, run the command:

$ exit

Alternatively, you can execute the commands directly on the container without accessing the shell using the following format:

$ lxc exec container-name command

For example, you can run the following commands that will update the package lists, check the version of OS running on the Debian container and check the date.

$ lxc exec tec-container1 apt update
$ lxc exec tec-container1 cat /etc/debian_version
$ lxc exec tec-container1 date

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Step 10: Pull / Push a File(s) to an LXC Container

Another operation you can carry out is to transfer files to and from the container. To demonstrate this, we will create a new directory in the LXD container and navigate into it.

# mkdir data && cd data

Next, we will create a sample file and add some data. To do so we will create a sample file with vim editor

# vim file1.txt

Next, we will type some sample text and save the file.

Hello World, Welcome to LXD containers.

To pull the file from the container to the local host system, we will use the syntax:

$ lxc file pull {container-name}/{path/to/file} {/path/to/local/dest}

In this case, the command will be:

$ lxc file pull tec-container2/root/data/file1.txt /home/tecmint

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

To push or copy a file from the local directory to the container use the syntax:

$ lxc file push {/path/to/file} {container-nane} /path/to/dest/dir/

In this case, we have a sample file in the home directory called file2.txt being copied to the /root/data/ path in the tec-container2 container.

$ lxc file push /home/tecmint/file2.txt tec-container2/root/data/

To confirm the existence of the file in the container, we will run:

$ lxc exec tec-container2 ls /root/data

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Step 11: Stop / Start / Restart and Delete LXC Containers

With the lxc command-line utility you can perform container management tasks such as stopping, starting, restarting and deleting containers.

To stop an lxc container, use the syntax:

$ lxc stop container-name

For example, to stop tec-container1, we will run the command:

$ lxc stop tec-container1

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

To start the lxc container, use the syntax:

$ lxc start container-name

For example, to start tec-container1, we will execute:

$ lxc start tec-container1

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

To restart both lxc containers, we will run the command:

$ lxc restart tec-container1
$ lxc restart tec-container2

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

To delete an lxc container, you must, first, stop the container and thereafter delete it. For example, to delete, we will run the commands:

$ lxc stop tec-container1
$ lxc delete tec-container1

Alternatively, you can combine these two commands as shown.

$ lxc stop tec-container1 && lxc delete tec-container1

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Step 12: Get Help on LXC Command-line Options

To get help on other command options provided by LXC, simply run the command:

$ lxc --help
OR
$ lxc command --help e.g
$ lxc file --help

Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux

Conclusion

That was a deep dive into LXD containers and how you can create and manage them using the lxc command-line utility tool. We trust that you found this guide helpful.

The above is the detailed content of Install LXC (Linux Containers) in RHEL, Rocky & AlmaLinux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to create a new, empty file from the command line? How to create a new, empty file from the command line? Jun 14, 2025 am 12:18 AM

There are three ways to create empty files in the command line: First, the simplest and safest use of the touch command, which is suitable for debugging scripts or placeholder files; Second, it is quickly created through > redirection but will clear existing content, which is suitable for initializing log files; Third, use echo"> file name to create a file with an empty string, or use echo-n""> file name to avoid line breaks. These three methods have their own applicable scenarios, and choosing the right method can help you complete the task more efficiently.

5 Best Open Source Mathematical Equation Editors for Linux 5 Best Open Source Mathematical Equation Editors for Linux Jun 18, 2025 am 09:28 AM

Are you looking for good software to write mathematical equations? If so, this article provides the top 5 equation editors that you can easily install on your favorite Linux distribution.In addition to being compatible with different types of mathema

How to Install Eclipse IDE in Debian, Ubuntu, and Linux Mint How to Install Eclipse IDE in Debian, Ubuntu, and Linux Mint Jun 14, 2025 am 10:40 AM

Eclipse is a free integrated development environment (IDE) that programmers around the world use to write software, primarily in Java, but also in other major programming languages using Eclipse plugins.The latest release of Eclipse IDE 2023?06 does

SCP Linux Command – Securely Transfer Files in Linux SCP Linux Command – Securely Transfer Files in Linux Jun 20, 2025 am 09:16 AM

Linux administrators should be familiar with the command-line environment. Since GUI (Graphical User Interface) mode in Linux servers is not commonly installed.SSH may be the most popular protocol to enable Linux administrators to manage the servers

24 Hilarious Linux Commands That Will Make You Laugh 24 Hilarious Linux Commands That Will Make You Laugh Jun 14, 2025 am 10:13 AM

Linux has a rich collection of commands, and while many of them are powerful and useful for various tasks, there are also some funny and whimsical commands that you can try out for amusement. 1. sl Command (Steam Locomotive) You might be aware of the

What is a PPA and how do I add one to Ubuntu? What is a PPA and how do I add one to Ubuntu? Jun 18, 2025 am 12:21 AM

PPA is an important tool for Ubuntu users to expand their software sources. 1. When searching for PPA, you should visit Launchpad.net, confirm the official PPA in the project official website or document, and read the description and user comments to ensure its security and maintenance status; 2. Add PPA to use the terminal command sudoadd-apt-repositoryppa:/, and then run sudoaptupdate to update the package list; 3. Manage PPAs to view the added list through the grep command, use the --remove parameter to remove or manually delete the .list file to avoid problems caused by incompatibility or stopping updates; 4. Use PPA to weigh the necessity and prioritize the situations that the official does not provide or require a new version of the software.

Gogo - Create Shortcuts to Directory Paths in Linux Gogo - Create Shortcuts to Directory Paths in Linux Jun 19, 2025 am 10:41 AM

Gogo is a remarkable tool to bookmark directories inside your Linux shell. It helps you create shortcuts for long and complex paths in Linux. This way, you no longer need to type or memorize lengthy paths on Linux.For example, if there's a directory

How to install Linux alongside Windows (dual boot)? How to install Linux alongside Windows (dual boot)? Jun 18, 2025 am 12:19 AM

The key to installing dual systems in Linux and Windows is partitioning and boot settings. 1. Preparation includes backing up data and compressing existing partitions to make space; 2. Use Ventoy or Rufus to make Linux boot USB disk, recommend Ubuntu; 3. Select "Coexist with other systems" or manually partition during installation (/at least 20GB, /home remaining space, swap optional); 4. Check the installation of third-party drivers to avoid hardware problems; 5. If you do not enter the Grub boot menu after installation, you can use boot-repair to repair the boot or adjust the BIOS startup sequence. As long as the steps are clear and the operation is done properly, the whole process is not complicated.

See all articles