LXD

De Jose Castillo Aliaga
Ir a la navegación Ir a la búsqueda

Instal·lació

 sudo apt-get install lxd
 newgrp lxd


En ubuntu, els usuaris han de formar part del grup LXD per poder utilitzar-lo.

Observem que passa si fem lxc sense paràmetres:

$ lxc
Usage: lxc [subcommand] [options]
Órdenes disponibles
	config     - Manage configuration.
	copy       - Copy containers within or in between lxd instances.
	delete     - Delete containers or container snapshots.
	exec       - Execute the specified command in a container.
	file       - Manage files on a container.
	help       - Presents details on how to use LXD.
	image      - Manipulate container images.
	info       - List information on LXD servers and containers.
	launch     - Launch a container from a particular image.
	list       - Lists the available resources.
	move       - Move containers within or in between lxd instances.
	profile    - Manage configuration profiles.
	publish    - Publish containers as images.
	remote     - Manage remote LXD servers.
	restart    - Changes state of one or more containers to restart.
	restore    - Set the current state of a resource back to a snapshot.
	snapshot   - Create a read-only snapshot of a container.
	start      - Changes state of one or more containers to start.
	stop       - Changes state of one or more containers to stop.
	version    - Prints the version number of this client tool.

Opciones:
  --all              Print less common commands.
  --debug            Print debug information.
  --verbose          Print verbose information.

Entorno:
  LXD_CONF           Path to an alternate client configuration directory.
  LXD_DIR            Path to an alternate server directory.

Contenidors i imatges

Si fem:

$ lxc image list
Generating a client certificate. This may take a minute...
If this is your first time using LXD, you should also run: sudo lxd init
To start your first container, try: lxc launch ubuntu:16.04

+-------+-------------+--------+--------------+-----+---------+-------------+
| ALIAS | FINGERPRINT | PUBLIC | DESCRIPCIÓN | ARQ | TAMAÑO | UPLOAD DATE |
+-------+-------------+--------+--------------+-----+---------+-------------+

Encara no tenim descarregada ninguna imatge, però ens dona l'opció de configurar en lxd init i de llançar un contenidor en lxc launch ubuntu:16.04.

jose@server:~$ lxc launch ubuntu:16.04
Creando sandless-yair
Retrieving image: 100%
Iniciando sandless-yair
jose@server:~$ lxc list
+---------------+---------+------+------+------------+-----------+
|    NOMBRE     | ESTADO  | IPV4 | IPV6 |    TIPO    | SNAPSHOTS |
+---------------+---------+------+------+------------+-----------+
| sandless-yair | RUNNING |      |      | PERSISTENT | 0         |
+---------------+---------+------+------+------------+-----------+
jose@server:~$ lxc image list
+-------+--------------+--------+---------------------------------------------+--------+----------+------------------------------+
| ALIAS | FINGERPRINT  | PUBLIC |                DESCRIPCIÓN                 |  ARQ   | TAMAÑO  |         UPLOAD DATE          |
+-------+--------------+--------+---------------------------------------------+--------+----------+------------------------------+
|       | de051f59f701 | no     | ubuntu 16.04 LTS amd64 (release) (20161011) | x86_64 | 143.12MB | Oct 14, 2016 at 9:43am (UTC) |
+-------+--------------+--------+---------------------------------------------+--------+----------+------------------------------+

Mirem cóm ha descarregat la imatge, ha creat el contenidor i la imatge està disponible ja en el sistema.

Backend

LXD pot anar directament al sistema d'arxius en /var/lib/lxd. No obstant, és més interessant utilitzar ZFS per els avantatges que proporciona.

Ús dels contenidors

  • Llistar contenidors lxc list
  • Llançar un contenidor nou lxc launch <imagen> [nombre]
  • Detindre un contenidor lxc stop <nombre>
  • Encendre un contenidor lxc start <nombre>
  • Obtindre un shell en un contenidor lxc exec <nombre> -- /bin/bash
  • Borrar un contenidor o snapshot lxc delete <nombre>

Snapshots

Moure contenidors

Copiar fitxers

Crear i gestionar imatges i tarballs

Quotes

Gestionar discos

Xarxa

Enllaços