LXD: Difference between revisions

From Alpine Linux
(added category)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= Introduction =
[https://linuxcontainers.org/lxd/introduction/ LXD] is a next generation system container manager. It offers a user experience similar to virtual machines but using Linux containers instead. It allows an easier management and deployment of [[LXC]] containers.  
[https://linuxcontainers.org/lxd/introduction/ LXD] is a next generation system container manager. It offers a user experience similar to virtual machines but using Linux containers instead.  
It allows an easier management and deployment of [[LXC]] containers.  


For now, Alpine Linux has a LXD package only for Edge so, first of all, you have to enable edge repositories.
== Prerequisites ==
* Enable the [[Repositories#Enabling_the_community_repository|community repository]]
* Enable [[D-Bus]] (needed for some containers as they refuse to start if unavailable)


Edit your /etc/apk/repositories:
== Installation ==


  http://dl-cdn.alpinelinux.org/alpine/v3.14/main
Then, install the {{pkg|lxd}} package and other necessary packages:{{Cmd|# apk add lxd lxd-client lxcfs}}
  http://dl-cdn.alpinelinux.org/alpine/v3.14/community
  @edge http://dl-cdn.alpinelinux.org/alpine/edge/main
  @edge http://dl-cdn.alpinelinux.org/alpine/edge/community
  @edge http://dl-cdn.alpinelinux.org/alpine/edge/testing


Then, let's start installing lxd and dbus packages (dbus is needed for some containers as they refuse to start if unavailable)
== Configuration ==


  apk add lxd@edge lxd-client@edge lxcfs dbus
Set some options to be able to run the containers as unprivileged:{{Cmd|<nowiki># echo "session optional pam_cgfs.so -c freezer,memory,name=systemd,unified" >> /etc/pam.d/system-login
# echo "lxc.idmap = u 0 100000 65536" >> /etc/lxc/default.conf
# echo "lxc.idmap = g 0 100000 65536" >> /etc/lxc/default.conf
# echo "root:100000:65536" >> /etc/subuid
# echo "root:100000:65536" >> /etc/subgid</nowiki>}}


Then, let's set some options to be able to run the containers as unprivileged:
If you plan to run systemd based Linux distributions (Debian, Ubuntu, etc.), add this to {{Path|/etc/conf.d/lxc}} file:{{Cat|/etc/conf.d/lxc|<nowiki>
systemd_container=yes</nowiki>}}


  echo "session optional pam_cgfs.so -c freezer,memory,name=systemd,unified" >> /etc/pam.d/system-login
and enable both lxc and lxd to start at boot:{{Cmd|<nowiki># rc-update add lxc
  echo "lxc.idmap = u 0 100000 65536" >> /etc/lxc/default.conf
# rc-update add lxd
  echo "lxc.idmap = g 0 100000 65536" >> /etc/lxc/default.conf
# rc-update add lxcfs</nowiki>}}
  echo "root:100000:65536" >> /etc/subuid
  echo "root:100000:65536" >> /etc/subgid


If you plan to run systemd based Linux distributions (Debian, Ubuntu, etc.), add this to /etc/conf.d/lxc:
Reboot and lxd should be working.
 
  systemd_container=yes
 
and enable both lxc and lxd at boot:
 
  rc-update add lxc
  rc-update add lxd
  rc-update add lxcfs


If you have problems, try to enable dbus:
== See also ==


  rc-update add dbus
* [https://documentation.ubuntu.com/lxd/latest/ Introduction to LXD on Ubuntu website]
 
[[Category:Virtualization]]
Reboot and lxd should be working.

Latest revision as of 17:43, 14 July 2025

LXD is a next generation system container manager. It offers a user experience similar to virtual machines but using Linux containers instead. It allows an easier management and deployment of LXC containers.

Prerequisites

Installation

Then, install the lxd package and other necessary packages:

# apk add lxd lxd-client lxcfs

Configuration

Set some options to be able to run the containers as unprivileged:

# echo "session optional pam_cgfs.so -c freezer,memory,name=systemd,unified" >> /etc/pam.d/system-login # echo "lxc.idmap = u 0 100000 65536" >> /etc/lxc/default.conf # echo "lxc.idmap = g 0 100000 65536" >> /etc/lxc/default.conf # echo "root:100000:65536" >> /etc/subuid # echo "root:100000:65536" >> /etc/subgid

If you plan to run systemd based Linux distributions (Debian, Ubuntu, etc.), add this to /etc/conf.d/lxc file:

Contents of /etc/conf.d/lxc

systemd_container=yes

and enable both lxc and lxd to start at boot:

# rc-update add lxc # rc-update add lxd # rc-update add lxcfs

Reboot and lxd should be working.

See also