Outils pour utilisateurs

Outils du site


issue140:tutoriel1

In my line of work I don't really get any exposure to containers, but the landscape is changing and if you want to stay relevant, you need to know. At first it was a scary prospect, until Daniel from the Full Circle Telegram group gave me a quick introduction to Vagrant. I had seen LXC on the internet, but assumed (incorrectly) that it was just another virtual machine manager. When I wanted to look into LXC, I was told about LXD, which is LXC with bells on.

Dans mon travail, je ne suis pas vraiment tourné vers les conteneurs, mais le paysage change et si vous voulez rester pertinent, vous devez les connaître. Au début, c'était une perspective effarante, jusqu'à ce que Daniel, du groupe Telegram du Full Circle, me fit une courte présentation de Vagrant. J'avais vu LXC sur Internet, mais j'en avais déduit (par erreur) que ce n'était qu'un autre gestionnaire de machine virtuelle. Quand j'ai voulu examiner LXC, on me parlait de LXD qui est LXC avec tout le bazar.

What is LXD? LXD is an open source container management extension for Linux Containers (LXC). LXD both improves upon existing LXC features and provides new features and functionality to build and manage Linux containers.

Qu'est-ce que LXD ?

LXD est une extension de gestion de conteneurs Open Source pour les conteneurs sous Linux (LXC). LXD améliore les fonctionnalités existantes de LXC tout en fournissant de nouvelles caractéristiques et fonctionnalités pour construire et gérer les conteneurs sous Linux.

And that is? Containers are a lightweight virtualisation technology that don't emulate hardware. Take the fifty cent tour with me. We can try LXD out online without installing anything at: https://linuxcontainers.org/lxd/try-it/

Et c'est quoi ?

Les conteneurs sont une technologie de virtualisation allégée qui n'émule pas le matériel.

Faisons un petit tour rapide ensemble.

Nous pouvons tester LXD en ligne, sans rien installer, à : https://linuxcontainers.org/lxd/try-it/

For those who want to try it at home, the LXD container hypervisors are supported and created by Ubuntu team, so installation is as simple as: sudo apt install lxd Our overview: 1. Set up and configure LXD 2. Create our first container 3. Launch a container

Pour ceux qui veulent l'essayer chez eux, les hyperviseurs de conteneur LXD sont supportés et créés par l'équipe d'Ubuntu ; ainsi, l'installation est aussi simple que :

sudo apt install lxd

En résumé : 1. Paramétrer et configurer LXD 2. Créer notre premier conteneur 3. Lancer un conteneur

Once LXD is installed, there will be a LXD group added to your list of groups. Just add your user to the group to be able to manage containers: sudo adduser gewgaw lxd Should the group not be created, add it yourself: newgrp lxd

Une fois LXD installé, vous trouverez un groupe LXD ajouté à votre liste de groupes. Il suffit d'ajouter votre utilisateur à ce groupe pour pouvoir gérer les conteneurs :

sudo adduser gewgaw lxd

Au cas où le groupe n'aurait été créé automatiquement, ajoutez-le.

newgrp lxd

Setup Instead of configuring LXD by hand, it comes with a handy set up: sudo lxd init You will need to answer the questions on screen to continue. This sets up the storage and networking etc. for you. Once you are done, verify your install with: lxc info LXD is built on top of LXC so the lxc commands are all valid.

Paramétrage

Au lieu de configurer LXD à la main, il arrive avec un paramétrage pratique : sudo lxd init

Vous devrez répondre aux questions à l'écran pour continuer. Ceci prépare le stockage et le réseau, etc. à votre place. Une fois fait, vérifiez votre installation avec : lxc info

LXD est construit par dessus LXC ; aussi toutes les commandes lxc sont valables.

Creation To create and start containers from images use the launch command: <lxc launch images: > examples: lxc launch images:centos/7/amd64 centos-c2 or: lxc launch images:opensuse/15.0/amd64 opensuse-stable-c8

Création

Pour créer et démarrer des conteneurs à partir d'images, utilisez la commande de lancement : <lxc launch images: >

exemples :

xc launch images:centos/7/amd64 centos-c2

ou:

lxc launch images:opensuse/15.0/amd64 opensuse-stable-c8

Can you see the pattern? Our container is now created. To confirm it was created, we can use the command: lxc list This will give you the name of your container, the state, the IP address and if it has snapshots. All the commands are self-explanatory, starting with: lxc then what you want to do. examples: lxc start, lxc stop, lxc info, lxc delete, lxc destroy, lxc create, lxc clone, etc. You can get a lot more info here: https://help.ubuntu.com/lts/serverguide/lxc.html

Pouvez-vous voir le motif ?

Notre conteneur est maintenant créé. Pour confirmer sa création, nous pouvons utiliser la commande : lxc list

Ceci vous donnera le nom de votre conteneur, son état, l'adresse IP et s'il a des instantanés. Toutes les commandes sont faciles à comprendre ; elle commencent toutes par lxc, suivi de ce que vous voulez faire.

exemples :

lxc start, lxc stop, lxc info, lxc delete, lxc destroy, lxc create, lxc clone, etc.

Vous pouvez trouver beaucoup plus d'infos ici : https://help.ubuntu.com/lts/serverguide/lxc.html

LXD is typically added to the Linux kernel. Packaged LXD distributions are available for numerous Linux distributions, including Fedora, Debian, openSUSE, Ubuntu, Alpine Linux, Arch Linux and Gentoo. We can also obtain LXD builds for Windows and OSX.

LXD est contenu classiquement dans le noyau Linux. Des distributions packagées de LXD sont disponibles pour de nombreuses distributions Linux, y compris Fedora, Debian, openSUSE, Ubuntu, Alpine Linux, Arch Linux et Gentoo. Vous pouvez aussi obtenir des compilations de LXD pour Windows et OSX.

Launch When you run 'lxc list', you will get a name in the first column. To start a container, simply type: 'lxc exec' and the name in that first column. For example: lxc exec centos-c2 adding “–” after the command, allows us to run a command or script in that container. Another example: lxc exec fedora28-c7 – dnf update To run a script you need to provide the full path to that script.

Lancement

Quand vous lancerez « lxc list », vous trouverez un nom dans la première colonne. Pour démarrer un conteneur, tapez simplement : « lxc exec » suivi du nom de la première colonne. Par exemple :

lxc exec centos-c2

L'ajout de « – » après la commande nous permet de lancer une commande ou un script dans ce conteneur. Autre exemple :

lxc exec fedora28-c7 – dnf update

Pour lancer un script, vous devez fournir le chemin complet vers ce script.

To work inside a container, add '– bash' to the end: lxc exec fedora28-c7 bash When you are done doing updates or installing software, simply type: exit

Pour travailler dans un conteneur, ajoutez « – bash » à la fin :

lxc exec fedora28-c7 – bash

Quand les mises à jour ou des installations de logiciels sont terminées, tapez simplement : exit

That is the quick overview on LXD. There is more to it, but you will pick up everything else very fast once you have this bit under your belt. Here you can find a list of commands: https://linuxcontainers.org/lxc/manpages/ Website: https://linuxcontainers.org/lxd/introduction/

C'est un aperçu rapide de LXD. Plus de choses existent à son sujet, mais vous récupérerez facilement le reste une fois que vous aurez digérez ce début.

Voici où vous trouverez une liste de commandes : https://linuxcontainers.org/lxc/manpages/

Site Web : https://linuxcontainers.org/lxd/introduction/

issue140/tutoriel1.txt · Dernière modification : 2019/01/07 11:15 de auntiee