Toolbox

As an immutable host, Fedora Silverblue is an excellent platform for container-based development and, for working with containers, buildah and podman are recommended.

Fedora Silverblue also comes with the toolbox utility, which uses containers to provide an environment where development tools and libraries can be installed and used.

Por que usar o toolbox?

Toolbox makes it easy to use a containerized environment for everyday software development and debugging. On immutable operating systems, like Fedora Silverblue, it provides a familiar package-based environment in which tools and libraries can be installed and used. However, toolbox can also be used on package-based systems.

Usar o Toolbox para executar seus fluxos de trabalho em contêineres traz várias vantagens:

  • Ele mantém o sistema operacional hospedeiro limpo e estável e ajuda a evitar a confusão que pode acontecer após a instalação de muitas ferramentas de desenvolvimento e pacotes.

  • Você obtém acesso a diferentes versões de distribuições com suporte, independentemente da versão em execução.

  • Os contêineres são uma boa maneira de isolar e organizar as dependências necessárias para diferentes projetos.

  • Os contêineres são um espaço seguro para experimentar: se algo der errado, é fácil jogar uma toolbox fora e começar de novo.

However, it is very important to note that toolbox containers are still integrated with your host system, so you should not attempt to do things or run software you otherwise wouldn’t on your host system. Toolbox containers are not completely isolated environments like virtual machines.

Como funciona

Toolbox takes the work out of using containers, by providing a small number of simple commands to create, enter, list and remove containers. It also integrates toolbox containers into your regular working environment, to make it easy for you to use them as an everyday development space.

Containers are created from images and those are usually a very stripped down version of distributions. In such images there are almost no tools and documentation available. The team behind Toolbox maintains a Fedora image where such tools and documentation are available, providing a good out of the box experience.

Each toolbox container is an environment that you can enter from the command line. Inside each one, you will find:

  • Seu nome de usuário e permissões existentes

  • Acesso para seu diretório pessoal (home) e várias outros locais

  • Acesso ao sistema e à sessão D-Bus, journal do sistema e Kerberos

  • Ferramentas de linha de comando comuns, incluindo um gerenciador de pacotes (por exemplo, DNF no Fedora)

In other words, toolbox containers look, feel and behave like a standard Linux command line environment. By connecting all this information, toolbox containers lose a certain amount of security gained by using the containers technology. Therefore, you should not treat toolbox containers as a sandbox where you can execute any script you would never run on any other system.

In most cases, when a command is run inside a container, the program from inside the container is used. However, there are a few special cases where the program on the host is used instead (using flatpak-spawn). One example of this is the toolbox command itself; this makes it possible to use toolbox from inside toolbox containers.

Instalação

Fedora Silverblue

Toolbox is preinstalled on Fedora Silverblue.

Fedora Workstation

O toolbox pode ser instalado no Fedora Workstation (ou em qualquer versão baseada em pacote do Fedora) com o seguinte comando:

$ sudo dnf install toolbox

Sua primeira toolbox

Depois que o toolbox é instalado, dois comandos simples são necessários para começar:

$ toolbox create

This will download an OCI image and create a toolbox container from it. Once this is complete, run:

$ toolbox enter

Uma vez dentro da toolbox, você pode acessar ferramentas de linha de comando comuns e instalar novas usando um gerenciador de pacotes (por exemplo, DNF no Fedora).

When the prompt is inside a toolbox, it is prepended with a diamond: this indicates that the prompt is inside a toolbox container. The diamond symbol may not be present if you use a custom shell theme.

Comandos e uso

toolbox create [opções] <nome>

Creates a toolbox container. This will download an OCI image if one isn’t available (this is required to create the container). By default an image matching the version of the host is used. If the host system does not have a matching image, a Fedora image is used instead.

Used without options, toolbox create will automatically name the container it creates. To create additional toolboxes, use the <name> argument.

Para usar uma versão específica do sistema host (por exemplo, Fedora 32 no Fedora 34), use a opção --release <lançamento> | -r <lançamento>.

Para usar uma distribuição diferente para criar um contêiner de toolbox (por exemplo, RHEL no Fedora), use a opção --distro <distro> | -d <distro>.

Para usar uma imagem diferente, use a opção --image <nome> | -i <nome>.

toolbox enter [opções] <nome>

Enters a toolbox for interactive use. Used without options, toolbox enter opens the default toolbox.

Para inserir uma toolbox com um nome específico, use o argumento nome.

Para inserir uma toolbox para uma distribuição diferente (por exemplo, Fedora no RHEL), use a opção --distro <distro> | -d <distro>.

Para entrar em uma toolbox com uma versão específica (por exemplo, RHEL 8.1 no RHEL 8.3), use o método `--release <lançamento> | opção -r <lançamento> `.

toolbox run [opções] <cmd> <arg …​>

Runs a command in a toolbox without entering it. Used without options, toolbox run runs the command in the default toolbox.

Para executar um comando em uma toolbox com um nome específico, use o método `--container <nome> | opção -c <nome> `.

Para executar um comando em uma toolbox para uma distribuição diferente (por exemplo, Fedora no RHEL), use a opção --distro <distro> | -d <distro>.

Para executar um comando em uma toolbox com versão específica (por exemplo, RHEL 8.1 no RHEL 8.3), use a opção `--release <lançamento> | -r <lançamento> `.

toolbox list [opções]

Lista contêineres e imagens de toolbox locais.

Para mostrar apenas contêineres, use o método --containers | -c.

Para mostrar apenas imagens, use a opção --images | -i.

toolbox rm [opções] <nome …​>

Remove um ou mais contêineres de toolbox.

A opção --force | -f remove os contêineres marcados mesmo se estiver em execução.

A opção --all | -a remove todos os contêineres de toolbox.

toolbox rmi [opções] <nome …​>

Remove uma ou mais imagens de toolbox.

A opção --force | -f remove as imagens marcadas e todos os contêineres que foram criados usando as imagens marcadas.

A opção --all | -a remove todas as imagens de toolbox.

toolbox --help

Mostra a página de manual do Toolbox.

Saindo de uma toolbox

Para retornar ao ambiente host, execute exit ou saia do shell atual (normalmente Ctrl+D).

Debaixo do capô

O toolbox usa as seguintes tecnologias:

Contato e problemas

Para relatar problemas, fazer sugestões ou contribuir com correções, consulte projeto do toolbox no GitHub.

Para entrar em contato com usuários e desenvolvedores do toolbox, use a instância do Discourse do Fedora, ou entre no canal IRC #silverblue no Libera.