Demo/docker #18

Merged
xavier merged 5 commits from demo/docker into main 2026-11-21 20:27:37 +01:00
15 changed files with 2494 additions and 2 deletions
Showing only changes of commit 372bf5d84b - Show all commits

No files matched your search

+7
View File
@@ -33,6 +33,13 @@ repository instead.
![Install a profile, update it after a change in LXD, import it back](demo/install.gif) ![Install a profile, update it after a change in LXD, import it back](demo/install.gif)
## Tutorials
Step-by-step use cases, from the clone of the repository to a ready instance:
- [Docker in an LXD container](demo/docker/README.en.md): install the
`docker-unprivileged` profile, launch an instance and use Docker.
## Usage ## Usage
Profiles can be used with the `lxc` client alone; [mise](https://mise.jdx.dev) Profiles can be used with the `lxc` client alone; [mise](https://mise.jdx.dev)
+7
View File
@@ -34,6 +34,13 @@ la modification dans le dépôt.
![Installation d'un profil, mise à jour après une modification dans LXD, puis import](demo/install.gif) ![Installation d'un profil, mise à jour après une modification dans LXD, puis import](demo/install.gif)
## Tutoriels
Des cas d'usage pas à pas, du clone du dépôt à une instance prête à servir :
- [Docker dans un conteneur LXD](demo/docker/README.md) : installer le profil
`docker-unprivileged`, lancer une instance et utiliser Docker.
## Utilisation ## Utilisation
Les profils s'utilisent avec le seul client `lxc` ; [mise](https://mise.jdx.dev) Les profils s'utilisent avec le seul client `lxc` ; [mise](https://mise.jdx.dev)
+13
View File
@@ -16,6 +16,8 @@ The `.cast` files can be played in Gitea's file view (asciinema player).
| `tour.yaml` | welcome message, `list`, `show`, `diff` (read only) | LXD | | `tour.yaml` | welcome message, `list`, `show`, `diff` (read only) | LXD |
| `lxc.yaml` | plain `lxc`, without mise: create a profile from its YAML file | LXD, profile `unattended-upgrades` not installed | | `lxc.yaml` | plain `lxc`, without mise: create a profile from its YAML file | LXD, profile `unattended-upgrades` not installed |
| `install.yaml` | `install`, diff and confirmation after a change in LXD, `import` | LXD, profile `unattended-upgrades` not installed | | `install.yaml` | `install`, diff and confirmation after a change in LXD, `import` | LXD, profile `unattended-upgrades` not installed |
| `docker/install.yaml` | [Docker tutorial](docker/README.en.md): clone the repository, install the `docker-unprivileged` profile, launch an instance and follow cloud-init | LXD, mise, no instance `docker` nor profile `docker-unprivileged` |
| `docker/usage.yaml` | [Docker tutorial](docker/README.en.md): `lxc exec`, then `lxc shell` and Docker commands in the instance | LXD, mise |
## Recording a demo ## Recording a demo
@@ -33,6 +35,17 @@ into the repository); their hidden epilogue restores the repository file as it
was and deletes the profile. These scenarios refuse to start if that profile is was and deletes the profile. These scenarios refuse to start if that profile is
already installed. already installed.
The scenarios of a tutorial live in a subdirectory (`docker/`), with their own
`setup.sh` preamble: it creates or checks what the scenario needs (instance,
profile, clone of the repository in a temporary directory), and its epilogue
removes what the demo created. These scenarios let the shell display its own
prompt (`prompt: ""` for autocast), so that the instance root shell opened by
`lxc shell` keeps its own.
`castfix.py` touches up each recording: it puts back the shell prompt that
autocast drops (at the start and after a `!Clear`) and speeds up the progress
dots of `cloud-init status --wait`.
agg draws the text itself, with fonts installed by mise in the demo environment agg draws the text itself, with fonts installed by mise in the demo environment
(nothing is installed on the system, which can be headless): (nothing is installed on the system, which can be headless):
[Inconsolata Nerd Font](https://www.nerdfonts.com) and [Inconsolata Nerd Font](https://www.nerdfonts.com) and
+13
View File
@@ -16,6 +16,8 @@ Les fichiers `.cast` se lisent dans la vue fichier de Gitea (lecteur asciinema).
| `tour.yaml` | message d'accueil, `list`, `show`, `diff` (lecture seule) | LXD | | `tour.yaml` | message d'accueil, `list`, `show`, `diff` (lecture seule) | LXD |
| `lxc.yaml` | `lxc` seul, sans mise : création d'un profil à partir de son fichier YAML | LXD, profil `unattended-upgrades` non installé | | `lxc.yaml` | `lxc` seul, sans mise : création d'un profil à partir de son fichier YAML | LXD, profil `unattended-upgrades` non installé |
| `install.yaml` | `install`, diff et confirmation après une modification dans LXD, `import` | LXD, profil `unattended-upgrades` non installé | | `install.yaml` | `install`, diff et confirmation après une modification dans LXD, `import` | LXD, profil `unattended-upgrades` non installé |
| `docker/install.yaml` | [tutoriel Docker](docker/README.md) : clone du dépôt, installation du profil `docker-unprivileged`, lancement d'une instance et suivi de cloud-init | LXD, mise, ni instance `docker` ni profil `docker-unprivileged` |
| `docker/usage.yaml` | [tutoriel Docker](docker/README.md) : `lxc exec`, puis `lxc shell` et commandes Docker dans l'instance | LXD, mise |
## Enregistrer une démo ## Enregistrer une démo
@@ -33,6 +35,17 @@ dans le dépôt) ; leur épilogue masqué remet le fichier du dépôt dans son
d'origine et supprime le profil. Ces scénarios refusent de démarrer si ce d'origine et supprime le profil. Ces scénarios refusent de démarrer si ce
profil est déjà installé. profil est déjà installé.
Les scénarios d'un tutoriel sont rangés dans un sous-dossier (`docker/`), avec
leur propre préambule `setup.sh` : il crée ou vérifie ce dont le scénario a
besoin (instance, profil, clone du dépôt dans un dossier temporaire) et son
épilogue supprime ce que la démo a créé. Ces scénarios laissent le shell
afficher lui-même son prompt (`prompt: ""` côté autocast), pour que le shell
root de l'instance ouvert par `lxc shell` garde le sien.
`castfix.py` retouche chaque enregistrement : il remet le prompt du shell que
autocast efface (au début et après un `!Clear`) et accélère les points de
progression de `cloud-init status --wait`.
agg dessine lui-même le texte, avec des polices installées par mise dans agg dessine lui-même le texte, avec des polices installées par mise dans
l'environnement de démo (rien n'est installé sur le système, qui peut être l'environnement de démo (rien n'est installé sur le système, qui peut être
sans interface graphique) : sans interface graphique) :
+43
View File
@@ -0,0 +1,43 @@
"""Post-process an autocast recording (asciicast v2), in place.
- Scenarios with an empty autocast prompt rely on the shell's own prompt (PS1):
autocast drops the very first one and the one a !Clear erases, so they are
put back (at the start, and after each screen clear).
- Progress dots (cloud-init status --wait prints one per second) are squeezed,
so that a long wait does not take a minute of the animation.
"""
import json
import re
import sys
DOT_GAP = 0.05
path = sys.argv[1]
with open(path, encoding="utf-8") as f:
header, *events = (json.loads(line) for line in f if line.strip())
ps1 = header.get("env", {}).get("PS1", "")
prompt = ps1.replace("AUTOCAST_PROMPT", "").replace("\\[", "").replace("\\]", "").replace("\\e", "\x1b")
first = next((e for e in events if e[1] == "o"), None)
if prompt and first and not first[2].startswith(prompt):
events.insert(0, [0.0, "o", prompt])
if prompt:
for event in events:
if event[1] == "o" and event[2].endswith("\x1b[2J\x1b[3J"):
event[2] += prompt
shift, previous = 0.0, 0.0
for event in events:
time = event[0]
gap = time - previous
previous = time
if event[1] == "o" and re.fullmatch(r"\.+", event[2]) and gap > DOT_GAP:
shift += gap - DOT_GAP
event[0] = round(time - shift, 6)
if events:
header["duration"] = events[-1][0]
with open(path, "w", encoding="utf-8") as f:
for record in (header, *events):
f.write(json.dumps(record, ensure_ascii=False) + "\n")
+249
View File
@@ -0,0 +1,249 @@
# Docker in an LXD container, in a few minutes
🇫🇷 [Lire en français](README.md)
Need a throwaway Docker to try an image, isolate a project or run a few
services without touching your machine? An LXD system container does the job
nicely: it starts in seconds, behaves like a small, complete Ubuntu machine,
and goes away with a single command.
This tutorial starts from scratch: get this repository, install the
`docker-unprivileged` profile in LXD, launch an instance that installs Docker
by itself at first boot, then use it.
![Clone the repository, install the profile, launch the instance and follow cloud-init](install.gif)
## What you need
- **LXD**, installed and initialized, with a user allowed to use it (member of
the `lxd` group):
```shell
sudo snap install lxd
sudo usermod -aG lxd "$USER" # then log in again
sudo lxd init --auto # default storage pool and lxdbr0 bridge
```
`lxc list` must answer without error. The tutorial also works with nested
LXD (LXD itself running in an LXD container): that is how the demos were
recorded.
- **[mise](https://mise.jdx.dev)**, which provides the repository tasks
(`list`, `show`, `install`…) and installs the small tools they use (`bat`,
`delta`, `gum`, `yq`):
```shell
curl https://mise.run | sh
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc # then reopen the shell
```
mise is optional: the [Without mise](#without-mise) section gives the
equivalent with plain `lxc`.
- **git**, and **internet access** from the instances (Ubuntu packages, the
`get.docker.com` script, Docker Hub).
- About **2 GB of free disk** on the LXD storage pool.
## 1. Get the repository
```shell
git clone https://gitea.cloud.logerais.com/xavier/lxd-profiles.git
mise trust lxd-profiles
cd lxd-profiles
mise install # tools used by the tasks (bat, delta, gum, yq), once
```
`mise trust` allows mise to load the repository configuration (`mise.toml`):
for safety, mise ignores configuration files it has not been explicitly told
to trust. Entering the directory displays a welcome message listing the
available tasks.
## 2. Choose and install the profile
Let's first see what the repository offers around Docker, and what is already
installed in LXD:
```shell
mise run list | grep -E 'PROFIL|docker'
```
```
PROFIL DESCRIPTION UTILISÉ FICHIER
⬜ docker A profile that deploy docker in an LXD container - profiles/containerization/docker.profile.yaml
⬜ docker-unprivileged A profile that deploy docker in an unprivileged L… - profiles/containerization/docker-unprivileged.profile.yaml
...
```
⬜ means "in the repository, not installed in LXD yet". Two profiles install
Docker:
- `docker` creates a **privileged** container: root in the container is root
on the host. It is the most permissive one, for the cases that require it.
- `docker-unprivileged` keeps the container **unprivileged** (root in the
container is an unprivileged user on the host). That is the one used here,
and it is enough for the vast majority of images.
Let's look at its content:
```shell
mise run show docker-unprivileged
```
```yaml
name: docker-unprivileged
description: "A profile that deploy docker in an unprivileged LXD container"
config:
linux.kernel_modules: overlay
security.nesting: "true"
# Requis pour les images dont les couches créent des device nodes ou des xattrs
security.syscalls.intercept.mknod: "true"
security.syscalls.intercept.setxattr: "true"
cloud-init.vendor-data: |
#cloud-config
package_update: true
package_upgrade: true
packages:
- curl
runcmd:
- curl https://get.docker.com | sh
timezone: Europe/Paris
locale: fr_FR.UTF-8
```
Nothing magic:
- `security.nesting` allows containers inside the container: Docker needs it
to create its own.
- `linux.kernel_modules: overlay` loads on the host the module of the
filesystem Docker uses for its images.
- the two `security.syscalls.intercept.*` let LXD handle, on behalf of the
container, the system calls some images make when their layers are
extracted, which an unprivileged container is not allowed to make.
- `cloud-init.vendor-data` is the first boot recipe: system update, then
Docker installation with the official script.
Install it in LXD:
```shell
mise run install docker-unprivileged
mise run list | grep -E 'PROFIL|docker-unprivileged' # ✅: up to date in LXD
```
## 3. Launch the instance and follow its installation
A profile is added at launch, after the `default` profile (which brings the
disk and the network):
```shell
lxc launch ubuntu:24.04 docker -p default -p docker-unprivileged
```
The instance starts in seconds, but cloud-init is still working in the
background: package upgrade, then Docker installation, about a minute and a
half. To wait for the end:
```shell
lxc exec docker -- cloud-init status --wait # one dot per second, then "status: done"
```
To follow the installation live, the cloud-init log reads like any file
(Ctrl+C to stop):
```shell
lxc exec docker -- tail -f /var/log/cloud-init-output.log
```
And if something goes wrong, `cloud-init status --long` sums up the errors.
Once done:
```shell
lxc exec docker -- tail -n 1 /var/log/cloud-init-output.log
lxc exec docker -- docker version --format 'Docker {{.Server.Version}}'
lxc list docker
```
The instance has two IPv4 addresses: its `eth0` interface on the LXD bridge,
and the `docker0` bridge Docker just created inside.
## 4. Use Docker
![hello-world with lxc exec, then a shell in the instance: nginx, docker ps, top, stats](usage.gif)
### From the host, with `lxc exec`
`lxc exec <instance> -- <command>` runs a command in the instance, without SSH
nor any setup. The classic:
```shell
lxc exec docker -- docker run --rm hello-world
```
### From a shell in the instance
For a real working session, `lxc shell` opens a root shell in the instance,
and Docker is used as on any machine:
```shell
lxc shell docker
```
```shell
docker run -d --name web -p 8080:80 nginx:alpine # a web server in the background
docker image ls # downloaded images
docker ps # running containers
docker top web -o pid,user,args # processes of the web container
docker stats --no-stream # CPU, memory, network
curl -s localhost:8080 | grep title # nginx answers
exit # back to the host
```
## Going further
- **Reach the service from the host.** Port 8080 is published by Docker inside
the instance. An LXD `proxy` device makes it reachable on the host (and so
from your network):
```shell
lxc config device add docker web proxy listen=tcp:0.0.0.0:8080 connect=tcp:127.0.0.1:8080
curl -s localhost:8080 | grep title
```
If port 8080 is already taken on the host, change the `listen` one. The
repository also has ready-made profiles for that (`proxy-http`,
`proxy-https`).
- **Combine profiles.** Profiles stack at launch: instance size
(`size-small`, `size-medium`…), automatic snapshots (`snapshots-daily`), a
dedicated volume for Docker data (`docker-volume-data`)…
```shell
lxc launch ubuntu:24.04 docker -p default -p docker-unprivileged -p size-medium -p snapshots-daily
```
- **Clean up.** The instance goes away with one command, Docker and its images
with it; the profile too, if no longer needed:
```shell
lxc delete --force docker
lxc profile delete docker-unprivileged
```
## Without mise
The repository files are regular LXD profiles: `lxc` is enough.
```shell
lxc profile create docker-unprivileged
lxc profile edit docker-unprivileged < profiles/containerization/docker-unprivileged.profile.yaml
lxc launch ubuntu:24.04 docker -p default -p docker-unprivileged
```
## Replaying the demos
The animations of this page are recorded from the `install.yaml` and
`usage.yaml` scenarios (see [how the demos are made](../README.en.md)):
```shell
MISE_ENV=demo mise run demo docker/install
MISE_ENV=demo mise run demo docker/usage
```
They create the `docker` instance and the `docker-unprivileged` profile, and
remove them at the end; `install` refuses to start if they already exist. In
the animation, the cloud-init wait is sped up.
+249
View File
@@ -0,0 +1,249 @@
# Docker dans un conteneur LXD, en quelques minutes
🇬🇧 [Read in English](README.en.md)
Vous voulez un Docker jetable pour tester une image, isoler un projet ou faire
tourner quelques services sans toucher à votre machine ? Un conteneur système
LXD fait très bien l'affaire : il démarre en quelques secondes, se comporte
comme une petite machine Ubuntu complète, et se supprime d'une commande.
Ce tutoriel part de zéro : on récupère ce dépôt, on installe le profil
`docker-unprivileged` dans LXD, on lance une instance qui installe Docker toute
seule au premier démarrage, puis on s'en sert.
![Clone du dépôt, installation du profil, lancement de l'instance et suivi de cloud-init](install.gif)
## Ce qu'il vous faut
- **LXD**, installé et initialisé, avec un utilisateur qui a le droit de
l'utiliser (membre du groupe `lxd`) :
```shell
sudo snap install lxd
sudo usermod -aG lxd "$USER" # puis se reconnecter
sudo lxd init --auto # pool de stockage et bridge lxdbr0 par défaut
```
`lxc list` doit répondre sans erreur. Le tutoriel fonctionne aussi dans un
LXD imbriqué (LXD lui-même dans un conteneur LXD), c'est d'ailleurs dans ces
conditions qu'ont été enregistrées les démos.
- **[mise](https://mise.jdx.dev)**, qui fournit les tâches du dépôt (`list`,
`show`, `install`…) et installe les petits outils qu'elles utilisent (`bat`,
`delta`, `gum`, `yq`) :
```shell
curl https://mise.run | sh
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc # puis rouvrir le shell
```
mise reste optionnel : la section [Sans mise](#sans-mise) donne l'équivalent
avec `lxc` seul.
- **git**, et un **accès à internet** depuis les instances (paquets Ubuntu,
script `get.docker.com`, Docker Hub).
- Environ **2 Go de disque** libres sur le pool de stockage LXD.
## 1. Récupérer le dépôt
```shell
git clone https://gitea.cloud.logerais.com/xavier/lxd-profiles.git
mise trust lxd-profiles
cd lxd-profiles
mise install # outils des tâches (bat, delta, gum, yq), une seule fois
```
`mise trust` autorise mise à charger la configuration du dépôt (`mise.toml`) :
par sécurité, mise ignore les fichiers de configuration qu'on ne lui a pas
explicitement désignés comme fiables. En entrant dans le dossier, un message
d'accueil rappelle les tâches disponibles.
## 2. Choisir et installer le profil
Commençons par voir ce que le dépôt propose autour de Docker, et ce qui est déjà
installé dans LXD :
```shell
mise run list | grep -E 'PROFIL|docker'
```
```
PROFIL DESCRIPTION UTILISÉ FICHIER
⬜ docker A profile that deploy docker in an LXD container - profiles/containerization/docker.profile.yaml
⬜ docker-unprivileged A profile that deploy docker in an unprivileged L… - profiles/containerization/docker-unprivileged.profile.yaml
...
```
⬜ signifie « présent dans le dépôt, pas encore installé dans LXD ». Deux profils
installent Docker :
- `docker` crée un conteneur **privilégié** : root dans le conteneur est root
sur l'hôte. C'est le plus permissif, à réserver aux cas qui l'exigent.
- `docker-unprivileged` garde le conteneur **non privilégié** (root dans le
conteneur est un utilisateur sans droits sur l'hôte). C'est celui qu'on
utilise ici, et il suffit pour l'immense majorité des images.
Regardons ce qu'il contient :
```shell
mise run show docker-unprivileged
```
```yaml
name: docker-unprivileged
description: "A profile that deploy docker in an unprivileged LXD container"
config:
linux.kernel_modules: overlay
security.nesting: "true"
# Requis pour les images dont les couches créent des device nodes ou des xattrs
security.syscalls.intercept.mknod: "true"
security.syscalls.intercept.setxattr: "true"
cloud-init.vendor-data: |
#cloud-config
package_update: true
package_upgrade: true
packages:
- curl
runcmd:
- curl https://get.docker.com | sh
timezone: Europe/Paris
locale: fr_FR.UTF-8
```
Rien de magique :
- `security.nesting` autorise les conteneurs dans le conteneur : c'est ce dont
Docker a besoin pour créer les siens.
- `linux.kernel_modules: overlay` charge sur l'hôte le module du système de
fichiers utilisé par Docker pour ses images.
- les deux `security.syscalls.intercept.*` laissent LXD traiter, à la place du
conteneur, les appels système que certaines images utilisent à l'extraction
de leurs couches et qu'un conteneur non privilégié n'a pas le droit de faire.
- `cloud-init.vendor-data` est la recette du premier démarrage : mise à jour
du système, puis installation de Docker avec le script officiel.
On l'installe dans LXD :
```shell
mise run install docker-unprivileged
mise run list | grep -E 'PROFIL|docker-unprivileged' # ✅ : à jour dans LXD
```
## 3. Lancer l'instance et suivre son installation
Un profil s'ajoute au lancement, après le profil `default` (qui apporte le disque
et le réseau) :
```shell
lxc launch ubuntu:24.04 docker -p default -p docker-unprivileged
```
L'instance démarre en quelques secondes, mais cloud-init travaille encore en
arrière-plan : mise à jour des paquets puis installation de Docker, environ une
minute et demie. Pour attendre la fin :
```shell
lxc exec docker -- cloud-init status --wait # un point par seconde, puis « status: done »
```
Pour suivre l'installation en direct, le journal de cloud-init se lit comme
n'importe quel fichier (Ctrl+C pour arrêter) :
```shell
lxc exec docker -- tail -f /var/log/cloud-init-output.log
```
Et si quelque chose se passe mal, `cloud-init status --long` résume les erreurs.
Une fois terminé :
```shell
lxc exec docker -- tail -n 1 /var/log/cloud-init-output.log
lxc exec docker -- docker version --format 'Docker {{.Server.Version}}'
lxc list docker
```
L'instance a deux adresses IPv4 : celle de son interface `eth0` sur le bridge
LXD, et celle du bridge `docker0` que Docker vient de créer à l'intérieur.
## 4. Utiliser Docker
![hello-world avec lxc exec, puis un shell dans l'instance : nginx, docker ps, top, stats](usage.gif)
### Depuis l'hôte, avec `lxc exec`
`lxc exec <instance> -- <commande>` exécute une commande dans l'instance, sans
SSH ni configuration. Le grand classique :
```shell
lxc exec docker -- docker run --rm hello-world
```
### Depuis un shell dans l'instance
Pour une vraie session de travail, `lxc shell` ouvre un shell root dans
l'instance, et Docker s'utilise comme sur n'importe quelle machine :
```shell
lxc shell docker
```
```shell
docker run -d --name web -p 8080:80 nginx:alpine # un serveur web en arrière-plan
docker image ls # images téléchargées
docker ps # conteneurs en cours
docker top web -o pid,user,args # processus du conteneur web
docker stats --no-stream # CPU, mémoire, réseau
curl -s localhost:8080 | grep title # nginx répond
exit # retour sur l'hôte
```
## Pour aller plus loin
- **Accéder au service depuis l'hôte.** Le port 8080 publié par Docker l'est
dans l'instance. Un device `proxy` LXD le rend joignable sur l'hôte (et donc
depuis votre réseau) :
```shell
lxc config device add docker web proxy listen=tcp:0.0.0.0:8080 connect=tcp:127.0.0.1:8080
curl -s localhost:8080 | grep title
```
Si le port 8080 est déjà pris sur l'hôte, changez celui de `listen`. Le dépôt
propose aussi des profils prêts à l'emploi pour ça (`proxy-http`,
`proxy-https`).
- **Combiner les profils.** Les profils s'empilent au lancement : taille de
l'instance (`size-small`, `size-medium`…), snapshots automatiques
(`snapshots-daily`), volume dédié aux données Docker (`docker-volume-data`)…
```shell
lxc launch ubuntu:24.04 docker -p default -p docker-unprivileged -p size-medium -p snapshots-daily
```
- **Faire le ménage.** L'instance se supprime d'une commande, Docker et ses
images avec ; le profil, s'il ne sert plus :
```shell
lxc delete --force docker
lxc profile delete docker-unprivileged
```
## Sans mise
Les fichiers du dépôt sont des profils LXD ordinaires : `lxc` suffit.
```shell
lxc profile create docker-unprivileged
lxc profile edit docker-unprivileged < profiles/containerization/docker-unprivileged.profile.yaml
lxc launch ubuntu:24.04 docker -p default -p docker-unprivileged
```
## Rejouer les démos
Les animations de cette page sont enregistrées à partir des scénarios
`install.yaml` et `usage.yaml` (voir [comment sont produites les démos](../README.md)) :
```shell
MISE_ENV=demo mise run demo docker/install
MISE_ENV=demo mise run demo docker/usage
```
Ils créent l'instance `docker` et le profil `docker-unprivileged`, puis les
suppriment à la fin ; `install` refuse de démarrer s'ils existent déjà.
Dans l'animation, l'attente de cloud-init est accélérée.
File diff suppressed because it is too large. Load diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 902 KiB

+50
View File
@@ -0,0 +1,50 @@
# Demo: Docker in an LXD container, from the clone of the repository to a ready instance
# (prerequisites: LXD, mise, no instance "docker" nor profile docker-unprivileged; removed at the end)
settings:
width: 156
height: 36
type_speed: 35ms
# Empty: the prompts are the shell's own (PS1), so that the instance's root shell keeps its own prompt
prompt: ""
timeout: 300s
# bash without rc files: the real prompt (PS1) is used to detect the end of commands
shell:
program: bash
args: [--norc, --noprofile]
prompt: AUTOCAST_PROMPT
line_split: " \\"
quit_command: exit
environment:
- {name: PS1, value: "\\[\\e[1;34m\\]lxd\\[\\e[0m\\] > AUTOCAST_PROMPT"}
- {name: PROMPT_COMMAND, value: "bind 'set enable-bracketed-paste off'"}
- {name: TERM, value: xterm-256color}
instructions:
- !Command {command: "source demo/docker/setup.sh install", hidden: true}
- !Marker Clone
- !Command {command: "# Get the repository and trust its mise configuration"}
- !Command {command: "git clone https://gitea.cloud.logerais.com/xavier/lxd-profiles.git"}
- !Command {command: "mise trust lxd-profiles"}
- !Command {command: "cd lxd-profiles"}
- !Wait 4s
- !Clear
- !Marker Profile
- !Command {command: "# Docker profiles available in the repository, not installed in LXD yet"}
- !Command {command: "mise run list | grep -E 'PROFIL|docker'"}
- !Wait 3s
- !Command {command: "mise run show docker-unprivileged"}
- !Wait 4s
- !Command {command: "mise run install docker-unprivileged"}
- !Command {command: "mise run list | grep -E 'PROFIL|docker-unprivileged'"}
- !Wait 3s
- !Clear
- !Marker Launch
- !Command {command: "# Launch an instance with the profile: cloud-init installs Docker at first boot"}
- !Command {command: "lxc launch ubuntu:24.04 docker -p default -p docker-unprivileged"}
- !Command {command: "lxc exec docker -- cloud-init status --wait"}
- !Command {command: "lxc exec docker -- tail -n 1 /var/log/cloud-init-output.log"}
- !Wait 2s
- !Command {command: "lxc exec docker -- docker version --format 'Docker {{.Server.Version}}'"}
- !Command {command: "lxc list docker"}
- !Wait 6s
- !Command {command: "demo_cleanup", hidden: true}
+52
View File
@@ -0,0 +1,52 @@
# shellcheck shell=bash
# Hidden preamble of the Docker demos (autocast), sourced from the repository root.
# source demo/docker/setup.sh install # nothing in LXD, fresh clone in a temporary directory
# source demo/docker/setup.sh usage # instance "docker" ready (created if missing)
# demo_cleanup (epilogue) removes what the demo created.
eval "$(mise activate bash)"
DEMO_INSTANCE=docker
DEMO_PROFILE=docker-unprivileged
DEMO_REPO=$PWD
DEMO_CREATED=
# Root shell of the instance, made recordable: its prompt ends with the marker
# autocast waits for, and its input is not echoed twice (no readline, no tty echo)
demo_instance_shell() {
lxc exec "$DEMO_INSTANCE" -- sh -c "cat >> /root/.bashrc" <<'RC'
PS1='\[\e[1;32m\]root@docker\[\e[0m\]:\w# AUTOCAST_PROMPT'
set +o emacs; stty -echo
RC
}
case "$1" in
install)
if lxc info "$DEMO_INSTANCE" >/dev/null 2>&1 || lxc profile show "$DEMO_PROFILE" >/dev/null 2>&1; then
echo "Instance $DEMO_INSTANCE or profile $DEMO_PROFILE already exists in LXD: the demo would remove them" >&2
exit 1
fi
DEMO_CREATED=yes
DEMO_TMP=$(mktemp -d)
cd "$DEMO_TMP" || exit 1
;;
usage)
if ! lxc info "$DEMO_INSTANCE" >/dev/null 2>&1; then
DEMO_CREATED=yes
mise run install --yes "$DEMO_PROFILE" >/dev/null
lxc launch ubuntu:24.04 "$DEMO_INSTANCE" -p default -p "$DEMO_PROFILE" >/dev/null
lxc exec "$DEMO_INSTANCE" -- cloud-init status --wait >/dev/null
fi
demo_instance_shell
;;
esac
demo_cleanup() {
cd "$DEMO_REPO" || return
if [ -n "$DEMO_TMP" ]; then
mise trust --untrust "$DEMO_TMP/lxd-profiles" >/dev/null 2>&1
rm -rf "$DEMO_TMP"
fi
if [ -n "$DEMO_CREATED" ]; then
lxc delete --force "$DEMO_INSTANCE" >/dev/null 2>&1
lxc profile delete "$DEMO_PROFILE" >/dev/null 2>&1
fi
}
+454
View File
@@ -0,0 +1,454 @@
{"version": 2, "width": 156, "height": 36, "timestamp": 1795282611, "duration": 37.680604, "env": {"TERM": "xterm-256color", "PROMPT_COMMAND": "bind 'set enable-bracketed-paste off'", "SHELL": "/usr/bin/bash", "PS1": "\\[\\e[1;34m\\]lxd\\[\\e[0m\\] > AUTOCAST_PROMPT"}}
[0.0, "o", "\u001b[1;34mlxd\u001b[0m > "]
[0.0, "o", ""]
[0.0, "m", "Exec"]
[0.035, "o", "#"]
[0.07, "o", " "]
[0.105, "o", "R"]
[0.14, "o", "u"]
[0.175, "o", "n"]
[0.21, "o", " "]
[0.245, "o", "a"]
[0.28, "o", " "]
[0.315, "o", "c"]
[0.35, "o", "o"]
[0.385, "o", "m"]
[0.42, "o", "m"]
[0.455, "o", "a"]
[0.49, "o", "n"]
[0.525, "o", "d"]
[0.56, "o", " "]
[0.595, "o", "i"]
[0.63, "o", "n"]
[0.665, "o", " "]
[0.7, "o", "t"]
[0.735, "o", "h"]
[0.77, "o", "e"]
[0.805, "o", " "]
[0.84, "o", "i"]
[0.875, "o", "n"]
[0.91, "o", "s"]
[0.945, "o", "t"]
[0.98, "o", "a"]
[1.015, "o", "n"]
[1.05, "o", "c"]
[1.085, "o", "e"]
[1.12, "o", " "]
[1.155, "o", "f"]
[1.19, "o", "r"]
[1.225, "o", "o"]
[1.26, "o", "m"]
[1.295, "o", " "]
[1.33, "o", "t"]
[1.365, "o", "h"]
[1.4, "o", "e"]
[1.435, "o", " "]
[1.47, "o", "h"]
[1.505, "o", "o"]
[1.54, "o", "s"]
[1.575, "o", "t"]
[1.61, "o", "\r\n"]
[1.613729, "o", "\u001b[1;34mlxd\u001b[0m > "]
[1.613729, "o", ""]
[1.648729, "o", "l"]
[1.683729, "o", "x"]
[1.718729, "o", "c"]
[1.753729, "o", " "]
[1.788729, "o", "e"]
[1.823729, "o", "x"]
[1.858729, "o", "e"]
[1.893729, "o", "c"]
[1.928729, "o", " "]
[1.963729, "o", "d"]
[1.998729, "o", "o"]
[2.033729, "o", "c"]
[2.068729, "o", "k"]
[2.103729, "o", "e"]
[2.138729, "o", "r"]
[2.173729, "o", " "]
[2.208729, "o", "-"]
[2.243729, "o", "-"]
[2.278729, "o", " "]
[2.313729, "o", "d"]
[2.348729, "o", "o"]
[2.383729, "o", "c"]
[2.418729, "o", "k"]
[2.453729, "o", "e"]
[2.488729, "o", "r"]
[2.523729, "o", " "]
[2.558729, "o", "r"]
[2.593729, "o", "u"]
[2.628729, "o", "n"]
[2.663729, "o", " "]
[2.698729, "o", "-"]
[2.733729, "o", "-"]
[2.768729, "o", "r"]
[2.803729, "o", "m"]
[2.838729, "o", " "]
[2.873729, "o", "h"]
[2.908729, "o", "e"]
[2.943729, "o", "l"]
[2.978729, "o", "l"]
[3.013729, "o", "o"]
[3.048729, "o", "-"]
[3.083729, "o", "w"]
[3.118729, "o", "o"]
[3.153729, "o", "r"]
[3.188729, "o", "l"]
[3.223729, "o", "d"]
[3.258729, "o", "\r\n"]
[3.508599, "o", "Unable to find image 'hello-world:latest' locally\r\n"]
[4.323996, "o", "latest: Pulling from library/hello-world\r\n"]
[4.939573, "o", "\r\n\u001b[1A\u001b[2K\r4f55086f7dd0: Pulling fs layer \r\u001b[1B"]
[5.333953, "o", "\u001b[1A\u001b[2K\r4f55086f7dd0: Download complete \r\u001b[1B\u001b[1A\u001b[2K\r4f55086f7dd0: Pull complete \r\u001b[1B"]
[5.532067, "o", "\r\n\u001b[1A\u001b[2K\rd5e71e642bf5: "]
[5.532075, "o", "Download complete \r\u001b[1B"]
[5.549241, "o", "Digest: sha256:1e4c05b897a751332ce85c7e9449da2d93514ea2dea6dbb0e2753c9e949b2bfa\r\nStatus: Downloaded newer image for hello-world:latest\r\n"]
[5.975424, "o", "\r\nHello from Docker!\r\nThis message shows that your installation appears to be working correctly.\r\n\r\nTo generate this message, Docker took the following steps:\r\n 1. The Docker client contacted the Docker daemon.\r\n 2. The Docker daemon pulled the \"hello-world\" image from the Docker Hub.\r\n (amd64)\r\n 3. The Docker daemon created a new container from that image which runs the\r\n executable that produces the output you are currently reading.\r\n 4. The Docker daemon streamed that output to the Docker client, which sent it\r\n to your terminal.\r\n\r\nTo try something more ambitious, you can run an Ubuntu container with:\r\n $ docker run -it ubuntu bash\r\n\r\nShare images, automate workflows, and more with a free Docker ID:\r\n https://hub.docker.com/\r\n\r\nFor more examples and ideas, visit:\r\n https://docs.docker.com/get-started/\r\n\r\n"]
[6.195088, "o", "\u001b[1;34mlxd\u001b[0m > "]
[6.195089, "o", ""]
[10.230089, "o", "\r\u001b[H\u001b[2J\u001b[3J\u001b[1;34mlxd\u001b[0m > "]
[10.265089, "o", ""]
[10.265089, "m", "Shell"]
[10.300089, "o", "#"]
[10.335089, "o", " "]
[10.370089, "o", "O"]
[10.405089, "o", "r"]
[10.440089, "o", " "]
[10.475089, "o", "o"]
[10.510089, "o", "p"]
[10.545089, "o", "e"]
[10.580089, "o", "n"]
[10.615089, "o", " "]
[10.650089, "o", "a"]
[10.685089, "o", " "]
[10.720089, "o", "s"]
[10.755089, "o", "h"]
[10.790089, "o", "e"]
[10.825089, "o", "l"]
[10.860089, "o", "l"]
[10.895089, "o", " "]
[10.930089, "o", "i"]
[10.965089, "o", "n"]
[11.000089, "o", " "]
[11.035089, "o", "t"]
[11.070089, "o", "h"]
[11.105089, "o", "e"]
[11.140089, "o", " "]
[11.175089, "o", "i"]
[11.210089, "o", "n"]
[11.245089, "o", "s"]
[11.280089, "o", "t"]
[11.315089, "o", "a"]
[11.350089, "o", "n"]
[11.385089, "o", "c"]
[11.420089, "o", "e"]
[11.455089, "o", " "]
[11.490089, "o", "a"]
[11.525089, "o", "n"]
[11.560089, "o", "d"]
[11.595089, "o", " "]
[11.630089, "o", "u"]
[11.665089, "o", "s"]
[11.700089, "o", "e"]
[11.735089, "o", " "]
[11.770089, "o", "D"]
[11.805089, "o", "o"]
[11.840089, "o", "c"]
[11.875089, "o", "k"]
[11.910089, "o", "e"]
[11.945089, "o", "r"]
[11.980089, "o", " "]
[12.015089, "o", "a"]
[12.050089, "o", "s"]
[12.085089, "o", " "]
[12.120089, "o", "o"]
[12.155089, "o", "n"]
[12.190089, "o", " "]
[12.225089, "o", "a"]
[12.260089, "o", "n"]
[12.295089, "o", "y"]
[12.330089, "o", " "]
[12.365089, "o", "m"]
[12.400089, "o", "a"]
[12.435089, "o", "c"]
[12.470089, "o", "h"]
[12.505089, "o", "i"]
[12.540089, "o", "n"]
[12.575089, "o", "e"]
[12.610089, "o", "\r\n"]
[12.6133, "o", "\u001b[1;34mlxd\u001b[0m > "]
[12.6133, "o", ""]
[12.6483, "o", "l"]
[12.6833, "o", "x"]
[12.7183, "o", "c"]
[12.7533, "o", " "]
[12.7883, "o", "s"]
[12.8233, "o", "h"]
[12.8583, "o", "e"]
[12.8933, "o", "l"]
[12.9283, "o", "l"]
[12.9633, "o", " "]
[12.9983, "o", "d"]
[13.0333, "o", "o"]
[13.0683, "o", "c"]
[13.1033, "o", "k"]
[13.1383, "o", "e"]
[13.1733, "o", "r"]
[13.2083, "o", "\r\n"]
[13.487959, "o", "\u001b[1;32mroot@docker\u001b[0m:~# "]
[13.48796, "o", ""]
[13.52296, "o", "d"]
[13.55796, "o", "o"]
[13.59296, "o", "c"]
[13.62796, "o", "k"]
[13.66296, "o", "e"]
[13.69796, "o", "r"]
[13.73296, "o", " "]
[13.76796, "o", "r"]
[13.80296, "o", "u"]
[13.83796, "o", "n"]
[13.87296, "o", " "]
[13.90796, "o", "-"]
[13.94296, "o", "d"]
[13.97796, "o", " "]
[14.01296, "o", "-"]
[14.04796, "o", "-"]
[14.08296, "o", "n"]
[14.11796, "o", "a"]
[14.15296, "o", "m"]
[14.18796, "o", "e"]
[14.22296, "o", " "]
[14.25796, "o", "w"]
[14.29296, "o", "e"]
[14.32796, "o", "b"]
[14.36296, "o", " "]
[14.39796, "o", "-"]
[14.43296, "o", "p"]
[14.46796, "o", " "]
[14.50296, "o", "8"]
[14.53796, "o", "0"]
[14.57296, "o", "8"]
[14.60796, "o", "0"]
[14.64296, "o", ":"]
[14.67796, "o", "8"]
[14.71296, "o", "0"]
[14.74796, "o", " "]
[14.78296, "o", "n"]
[14.81796, "o", "g"]
[14.85296, "o", "i"]
[14.88796, "o", "n"]
[14.92296, "o", "x"]
[14.95796, "o", ":"]
[14.99296, "o", "a"]
[15.02796, "o", "l"]
[15.06296, "o", "p"]
[15.09796, "o", "i"]
[15.13296, "o", "n"]
[15.16796, "o", "e"]
[15.20296, "o", "\r\n"]
[15.220856, "o", "Unable to find image 'nginx:alpine' locally\r\n"]
[16.015379, "o", "alpine: Pulling from library/nginx\r\n"]
[16.382424, "o", "\r\n\u001b[1A\u001b[2K\r881fc932939e: Pulling fs layer \r\u001b[1B\r\n\u001b[1A\u001b[2K\r61d8f4c85a74: "]
[16.383325, "o", "Pulling fs layer \r\u001b[1B\r\n\u001b[1A\u001b[2K\r1dc588c89da1: Pulling fs layer \r\u001b[1B\r\n\u001b[1A\u001b[2K\rc4f3d97811f6: Pulling fs layer \r\u001b[1B\r\n\u001b[1A\u001b[2K\r77a3bfea78f5: Pulling fs layer \r\u001b[1B\r\n\u001b[1A\u001b[2K\r04c3905a997c: Pulling fs layer \r\u001b[1B\r\n\u001b[1A\u001b[2K\r4c8c172c6586: Pulling fs layer \r\u001b[1B"]
[16.383358, "o", "\r\n\u001b[1A\u001b[2K\r7cb374baf968: Pulling fs layer \r\u001b[1B"]
[16.646108, "o", "\u001b[7A\u001b[2K\r61d8f4c85a74: Download complete \r\u001b[7B"]
[16.646215, "o", "\u001b[8A\u001b[2K\r881fc932939e: Download complete \r\u001b[8B"]
[16.646222, "o", "\u001b[6A\u001b[2K\r1dc588c89da1: Downloading [==================================================>] 1.211kB/1.211kB\r\u001b[6B"]
[16.646661, "o", "\u001b[8A\u001b[2K\r881fc932939e: Extracting 1 s\r\u001b[8B"]
[16.7513, "o", "\u001b[6A\u001b[2K\r1dc588c89da1: Download complete \r\u001b[6B\u001b[5A\u001b[2K\rc4f3d97811f6: Downloading [============> ] 5.243MB/20.54MB\r\u001b[5B"]
[16.753518, "o", "\u001b[8A\u001b[2K\r881fc932939e: Extracting 1 s\r\u001b[8B"]
[16.845026, "o", "\u001b[5A\u001b[2K\rc4f3d97811f6: Downloading [======================================> ] 15.73MB/20.54MB\r\u001b[5B"]
[16.84839, "o", "\u001b[4A\u001b[2K\r77a3bfea78f5: Download complete \r\u001b[4B"]
[16.848426, "o", "\u001b[2A"]
[16.848478, "o", "\u001b[2K\r4c8c172c6586: Download complete \r\u001b[2B"]
[16.84929, "o", "\u001b[8A\u001b[2K\r881fc932939e: Extracting 1 s\r\u001b[8B"]
[16.945193, "o", "\u001b[1A\u001b[2K\r7cb374baf968: Downloading [==================================================>] 965B/965B\r\u001b[1B"]
[16.945626, "o", "\u001b[3A\u001b[2K\r04c3905a997c: Download complete \r\u001b[3B"]
[16.946084, "o", "\u001b[8A\u001b[2K\r881fc932939e: Extracting 1 s\r\u001b[8B"]
[17.04583, "o", "\u001b[5A\u001b[2K"]
[17.045851, "o", "\rc4f3d97811f6: Download complete \r\u001b[5B\u001b[1A\u001b[2K\r7cb374baf968: Download complete \r\u001b[1B"]
[17.046393, "o", "\u001b[8A\u001b[2K"]
[17.046438, "o", "\r881fc932939e: Extracting 1 s\r\u001b[8B"]
[17.146048, "o", "\u001b[8A\u001b[2K\r881fc932939e: Pull complete \r\u001b[8B"]
[17.248037, "o", "\r\n\u001b[1A\u001b[2K\r79979b969278: Download complete \r\u001b[1B\r\n\u001b[1A\u001b[2K\r33247e384332: Download complete \r\u001b[1B"]
[17.24941, "o", "\u001b[6A\u001b[2K\r77a3bfea78f5: Extracting 1 s\r\u001b[6B"]
[17.34931, "o", "\u001b[6A\u001b[2K\r77a3bfea78f5: Extracting 1 s\r\u001b[6B"]
[17.446575, "o", "\u001b[6A\u001b[2K\r"]
[17.446615, "o", "77a3bfea78f5: Pull complete \r\u001b[6B"]
[17.447027, "o", "\u001b[5A\u001b[2K\r04c3905a997c: Extracting 1 s\r\u001b[5B"]
[17.548262, "o", "\u001b[5A\u001b[2K\r04c3905a997c: Pull complete \r\u001b[5B"]
[17.548612, "o", "\u001b[3A\u001b[2K\r7cb374baf968: Pull complete \r\u001b[3B"]
[17.647564, "o", "\u001b[8A\u001b[2K\r1dc588c89da1: Extracting 1 s\r\u001b[8B"]
[17.647948, "o", "\u001b[4A\u001b[2K\r4c8c172c6586: Pull complete \r\u001b[4B"]
[17.745396, "o", "\u001b[8A\u001b[2K\r1dc588c89da1: Pull complete \r\u001b[8B"]
[17.845379, "o", "\u001b[9A\u001b[2K\r61d8f4c85a74: Pull complete \r\u001b[9B"]
[17.845712, "o", "\u001b[7A\u001b[2K\rc4f3d97811f6: Extracting 1 s\r\u001b[7B"]
[17.946718, "o", "\u001b[7A\u001b[2K\rc4f3d97811f6: Extracting 1 s\r\u001b[7B"]
[18.046347, "o", "\u001b[7A\u001b[2K\rc4f3d97811f6: Extracting 1 s\r\u001b[7B"]
[18.145277, "o", "\u001b[7A\u001b[2K\rc4f3d97811f6: Extracting 1 s\r\u001b[7B"]
[18.245237, "o", "\u001b[7A\u001b[2K\rc4f3d97811f6: Extracting 1 s\r\u001b[7B"]
[18.347123, "o", "\u001b[7A\u001b[2K"]
[18.34812, "o", "\rc4f3d97811f6: Extracting 1 s\r\u001b[7B"]
[18.445102, "o", "\u001b[7A\u001b[2K\rc4f3d97811f6: Pull complete \r\u001b[7B"]
[18.470357, "o", "Digest: sha256:fb4658584bd9a916ffb6f6e365f97c25cfdb2923801f551ea08356e695f14ff7\r\nStatus: Downloaded newer image for nginx:alpine\r\n"]
[18.653218, "o", "4356be02dd2c9bbd03025fb22366e564d780c7622c489e8857b3510e120c78c3\r\n"]
[18.876775, "o", "\u001b[1;32mroot@docker\u001b[0m:~# "]
[18.876776, "o", ""]
[20.911776, "o", "c"]
[20.946776, "o", "l"]
[20.981776, "o", "e"]
[21.016776, "o", "a"]
[21.051776, "o", "r"]
[21.086776, "o", "\r\n"]
[21.087913, "o", "\u001b[H\u001b[2J\u001b[3J\u001b[1;34mlxd\u001b[0m > "]
[21.088026, "o", "\u001b[1;32mroot@docker\u001b[0m:~# "]
[21.088026, "o", ""]
[21.123026, "o", "d"]
[21.158026, "o", "o"]
[21.193026, "o", "c"]
[21.228026, "o", "k"]
[21.263026, "o", "e"]
[21.298026, "o", "r"]
[21.333026, "o", " "]
[21.368026, "o", "i"]
[21.403026, "o", "m"]
[21.438026, "o", "a"]
[21.473026, "o", "g"]
[21.508026, "o", "e"]
[21.543026, "o", " "]
[21.578026, "o", "l"]
[21.613026, "o", "s"]
[21.648026, "o", "\r\n"]
[21.714674, "o", " \u001b[1m\u001b[106m\u001b[30mi\u001b[0m\u001b[0m \u001b[96mInfo → \u001b[0m\u001b[0m \u001b[38;5;0m\u001b[48;5;14m U \u001b[0m In Use\r\n\u001b[39m\u001b[1mIMAGE\u001b[0m \u001b[39m\u001b[1mID\u001b[0m \u001b[39m\u001b[1mDISK USAGE\u001b[0m \u001b[39m\u001b[1mCONTENT SIZE\u001b[0m \u001b[39m\u001b[1mEXTRA\u001b[0m\r\n\u001b[34m\u001b[1mhello-world:latest\u001b[0m \u001b[39m1e4c05b897a7\u001b[0m "]
[21.714735, "o", " \u001b[39m21.8kB\u001b[0m \u001b[39m9.49kB\u001b[0m \r\n\u001b[34m\u001b[1mnginx:alpine\u001b[0m \u001b[39mfb4658584bd9\u001b[0m \u001b[39m95.7MB\u001b[0m \u001b[39m27.2MB\u001b[0m \u001b[38;5;0m\u001b[48;5;14m U \u001b[0m \r\n"]
[21.727198, "o", "\u001b[1;32mroot@docker\u001b[0m:~# "]
[21.727198, "o", ""]
[21.762198, "o", "d"]
[21.797198, "o", "o"]
[21.832198, "o", "c"]
[21.867198, "o", "k"]
[21.902198, "o", "e"]
[21.937198, "o", "r"]
[21.972198, "o", " "]
[22.007198, "o", "p"]
[22.042198, "o", "s"]
[22.077198, "o", "\r\n"]
[22.103539, "o", "CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES\r\n4356be02dd2c nginx:alpine \"/docker-entrypoint.…\" 1 second ago Up Less than a second 0.0.0.0:8080->80/tcp, [::]:8080->80/tcp web\r\n"]
[22.104791, "o", "\u001b[1;32mroot@docker\u001b[0m:~# "]
[22.104791, "o", ""]
[25.139791, "o", "d"]
[25.174791, "o", "o"]
[25.209791, "o", "c"]
[25.244791, "o", "k"]
[25.279791, "o", "e"]
[25.314791, "o", "r"]
[25.349791, "o", " "]
[25.384791, "o", "t"]
[25.419791, "o", "o"]
[25.454791, "o", "p"]
[25.489791, "o", " "]
[25.524791, "o", "w"]
[25.559791, "o", "e"]
[25.594791, "o", "b"]
[25.629791, "o", " "]
[25.664791, "o", "-"]
[25.699791, "o", "o"]
[25.734791, "o", " "]
[25.769791, "o", "p"]
[25.804791, "o", "i"]
[25.839791, "o", "d"]
[25.874791, "o", ","]
[25.909791, "o", "u"]
[25.944791, "o", "s"]
[25.979791, "o", "e"]
[26.014791, "o", "r"]
[26.049791, "o", ","]
[26.084791, "o", "a"]
[26.119791, "o", "r"]
[26.154791, "o", "g"]
[26.189791, "o", "s"]
[26.224791, "o", "\r\n"]
[26.254129, "o", "PID USER COMMAND\r\n10702 root nginx: master process nginx -g daemon off;\r\n10778 message+ nginx: worker process\r\n10779 message+ nginx: worker process\r\n10780 message+ nginx: worker process\r\n10781 "]
[26.254218, "o", "message+ nginx: worker process\r\n10782 message+ nginx: worker process\r\n10783 message+ nginx: worker process\r\n10784 message+ "]
[26.254253, "o", "nginx: worker process"]
[26.254266, "o", "\r\n10786"]
[26.254286, "o", " message+ nginx: worker process\r\n"]
[26.257188, "o", "\u001b[1;32mroot@docker\u001b[0m:~# "]
[26.257189, "o", ""]
[26.292189, "o", "d"]
[26.327189, "o", "o"]
[26.362189, "o", "c"]
[26.397189, "o", "k"]
[26.432189, "o", "e"]
[26.467189, "o", "r"]
[26.502189, "o", " "]
[26.537189, "o", "s"]
[26.572189, "o", "t"]
[26.607189, "o", "a"]
[26.642189, "o", "t"]
[26.677189, "o", "s"]
[26.712189, "o", " "]
[26.747189, "o", "-"]
[26.782189, "o", "-"]
[26.817189, "o", "n"]
[26.852189, "o", "o"]
[26.887189, "o", "-"]
[26.922189, "o", "s"]
[26.957189, "o", "t"]
[26.992189, "o", "r"]
[27.027189, "o", "e"]
[27.062189, "o", "a"]
[27.097189, "o", "m"]
[27.132189, "o", "\r\n"]
[28.176777, "o", "CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS\r\n4356be02dd2c web 0.00% 7.477MiB / 30.26GiB 0.02% 646B / 84B 0B / 0B 9\r\n"]
[28.177542, "o", "\u001b[1;32mroot@docker\u001b[0m:~# "]
[28.177543, "o", ""]
[31.212543, "o", "c"]
[31.247543, "o", "u"]
[31.282543, "o", "r"]
[31.317543, "o", "l"]
[31.352543, "o", " "]
[31.387543, "o", "-"]
[31.422543, "o", "s"]
[31.457543, "o", " "]
[31.492543, "o", "l"]
[31.527543, "o", "o"]
[31.562543, "o", "c"]
[31.597543, "o", "a"]
[31.632543, "o", "l"]
[31.667543, "o", "h"]
[31.702543, "o", "o"]
[31.737543, "o", "s"]
[31.772543, "o", "t"]
[31.807543, "o", ":"]
[31.842543, "o", "8"]
[31.877543, "o", "0"]
[31.912543, "o", "8"]
[31.947543, "o", "0"]
[31.982543, "o", " "]
[32.017543, "o", "|"]
[32.052543, "o", " "]
[32.087543, "o", "g"]
[32.122543, "o", "r"]
[32.157543, "o", "e"]
[32.192543, "o", "p"]
[32.227543, "o", " "]
[32.262543, "o", "t"]
[32.297543, "o", "i"]
[32.332543, "o", "t"]
[32.367543, "o", "l"]
[32.402543, "o", "e"]
[32.437543, "o", "\r\n"]
[32.443973, "o", "<\u001b[01;31m\u001b[Ktitle\u001b[m\u001b[K>Welcome to nginx!</\u001b[01;31m\u001b[Ktitle\u001b[m\u001b[K>\r\n"]
[32.444591, "o", "\u001b[1;32mroot@docker\u001b[0m:~# "]
[32.444591, "o", ""]
[32.479591, "o", "e"]
[32.514591, "o", "x"]
[32.549591, "o", "i"]
[32.584591, "o", "t"]
[32.619591, "o", "\r\n"]
[32.619844, "o", "logout\r\n"]
[32.645603, "o", "\u001b[1;34mlxd\u001b[0m > "]
[32.645604, "o", ""]
[37.680604, "o", "\r\n"]
Binary file not shown.

After

Width:  |  Height:  |  Size: 378 KiB

+44
View File
@@ -0,0 +1,44 @@
# Demo: using Docker in the LXD instance, with lxc exec then from a shell in the instance
# (prerequisites: LXD, mise; instance "docker" created with its profile if missing, then removed at the end)
settings:
width: 156
height: 36
type_speed: 35ms
# Empty: the prompts are the shell's own (PS1), so that the instance's root shell keeps its own prompt
prompt: ""
timeout: 300s
# bash without rc files: the real prompt (PS1) is used to detect the end of commands
shell:
program: bash
args: [--norc, --noprofile]
prompt: AUTOCAST_PROMPT
line_split: " \\"
quit_command: exit
environment:
- {name: PS1, value: "\\[\\e[1;34m\\]lxd\\[\\e[0m\\] > AUTOCAST_PROMPT"}
- {name: PROMPT_COMMAND, value: "bind 'set enable-bracketed-paste off'"}
- {name: TERM, value: xterm-256color}
instructions:
- !Command {command: "source demo/docker/setup.sh usage", hidden: true}
- !Marker Exec
- !Command {command: "# Run a command in the instance from the host"}
- !Command {command: "lxc exec docker -- docker run --rm hello-world"}
- !Wait 4s
- !Clear
- !Marker Shell
- !Command {command: "# Or open a shell in the instance and use Docker as on any machine"}
- !Command {command: "lxc shell docker"}
- !Command {command: "docker run -d --name web -p 8080:80 nginx:alpine"}
- !Wait 2s
- !Command {command: "clear"}
- !Command {command: "docker image ls"}
- !Command {command: "docker ps"}
- !Wait 3s
- !Command {command: "docker top web -o pid,user,args"}
- !Command {command: "docker stats --no-stream"}
- !Wait 3s
- !Command {command: "curl -s localhost:8080 | grep title"}
- !Command {command: "exit"}
- !Wait 5s
- !Command {command: "demo_cleanup", hidden: true}
+3 -2
View File
@@ -10,14 +10,15 @@
"http:noto-color-emoji" = { version = "2026-09-24", url = "https://github.com/googlefonts/noto-emoji/raw/v2026-09-24-unicode18_0/2D/fonts/NotoColorEmoji.ttf" } "http:noto-color-emoji" = { version = "2026-09-24", url = "https://github.com/googlefonts/noto-emoji/raw/v2026-09-24-unicode18_0/2D/fonts/NotoColorEmoji.ttf" }
[tasks.demo] [tasks.demo]
description = "Enregistre une démo (demo/<nom>.cast avec autocast, puis demo/<nom>.gif avec agg)" description = "Enregistre une démo (demo/<nom>.cast avec autocast, retouché par demo/castfix.py, puis demo/<nom>.gif avec agg)"
usage = ''' usage = '''
arg "<name>" help="Scénario (demo/<name>.yaml)" { arg "<name>" help="Scénario (demo/<name>.yaml)" {
choices "tour" "install" "lxc" choices "tour" "install" "lxc" "docker/install" "docker/usage"
} }
''' '''
run = ''' run = '''
autocast --overwrite "demo/${usage_name}.yaml" "demo/${usage_name}.cast" autocast --overwrite "demo/${usage_name}.yaml" "demo/${usage_name}.cast"
python3 -I demo/castfix.py "demo/${usage_name}.cast"
agg --quiet --theme monokai \ agg --quiet --theme monokai \
--font-dir "$(mise where github:ryanoasis/nerd-fonts)" \ --font-dir "$(mise where github:ryanoasis/nerd-fonts)" \
--font-dir "$(mise where http:noto-color-emoji)" \ --font-dir "$(mise where http:noto-color-emoji)" \