# LXC

# Commandes de base

ATTENTION : il faut être root pour lister les conteneurs

Pour voir la liste des conteneurs installés, leur état et leurs adresses réseau :

```bash
lxc-ls -f
```

Pour démarrer un conteneur :

```bash
lxc-start -n <nom-du-conteneur>
```

Pour arrêter un conteneur :

```bash
lxc-stop -n <nom-du-conteneur>
```

Pour obtenir des informations détaillées sur le conteneur :

```
lxc-info -n <nom du conteneur>
```

Pour lancer un shell en mode superutilisateur

```
lxc-attach -n <nom du conteneur> -- /bin/bash
```

Pour exécuter une commande en mode superutilisateur

```
lxc-attach -n <nom du conteneur> -- <commande>
```

Pour supprimer un conteneur

```
lxc-destroy -n <nom du conteneur>
```

Pour créer un snapshot de l'état d'un conteneur

```
 lxc-snapshot -n <nom du conteneur>
```

Pour voir liste des snapshots disponible pour un conteneur

```
lxc-snapshot -n <nom du conteneur> -L
```

Pour restaurer un snapshot

```
lxc-snapshot -n <nom du conteneur> -r <nom du snapshot>
```

Pour supprimer un snapshot

```
lxc-snapshot -n <nom du conteneur> -d <nom du snapshot>
```

Pour copier un conteneur

```
lxc-copy -n <nom du conteneur> -N <nom du nouveau conteneur>
```

# Installation et configuration réseau

Installation

```bash
apt-get install lxc libvirt0 libpam-cgfs bridge-utils uidmap
```

/etc/default/lxc-net

```bash
USE_LXC_BRIDGE="true"
LXC_ADDR="10.10.10.254"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.10.10.0/24"
```