Debugging con Toolbx

L’immagine di FCOS è mantenuta minima per progettazione, al fine di ridurre la dimensione dell’immagine e la superficie di attacco. Ciò significa che non include tutti gli strumenti di risoluzione dei problemi che un sistema operativo normale potrebbe includere. Invece, l’approccio consigliato è utilizzare i container con l’utilità [toolbox](https://containertoolbx.org/) inclusa nell’immagine.

Cos’è Toolbx?

Toolbox è un’utility che ti permette di creare container privilegiati per il debug e la risoluzione dei problemi della tua istanza. Si tratta di un wrapper attorno a podman, che avvia container a lungo termine con mount e namespace di default per facilitare il debug del sistema host.

Questi container possono quindi essere utilizzati per installare strumenti necessari per la risoluzione dei problemi.

Using Toolbx

You can create a new toolbox by running the command below. On the first run it will ask you if you want to download an image. Answer yes with y.

toolbox create my_toolbox

You can then list all the running toolboxes running on the host. This should show you your newly created toolbox. In this case, it is named my_toolbox.

toolbox list

As pointed out by the output of the toolbox create my_toolbox command, you can enter the following command to enter your toolbox.

Entra nel contenitore Toolbox chiamato my_toolbox

Now that you’re in the container, you can use the included dnf package manager to install packages. For example, let’s install strace to look at read syscall done by the host’s toolbox utility.

sudo dnf install strace
# Some hosts directories are mounted at /run/host
strace -eread /run/host/usr/bin/toolbox list

Once done with your container, you can exit the container and then remove it from the host with the following command.

toolbox rm --force my_toolbox
Toolbx allows you to create toolboxes with your custom images. You can find more details in the toolbox manpages.