Toolbx

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

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

Why use toolbx?

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

Using Toolbx for running your workflows in a containerized manner brings you several advantages:

  • It keeps the host OS clean and stable, and helps to avoid the clutter that can happen after installing lots of development tools and packages.

  • You get access to different versions of supported distributions independent of the version you are running.

  • Containers are a good way to isolate and organise the dependencies needed for different projects.

  • Containers are a safe space to experiment: if things go wrong, it’s easy to throw a toolbox away and start again.

However, it is very important to note that toolbx 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. Toolbx containers are not completely isolated environments like virtual machines.

How it works

Toolbx 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 toolbx 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 Toolbx maintains a Fedora image where such tools and documentation are available, providing a good out of the box experience.

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

  • Your existing username and permissions

  • Access to your home directory and several other locations

  • Access to both system and session D-Bus, system journal and Kerberos

  • Common command lines tools, including a package manager (e.g., DNF on Fedora)

In other words, toolbx containers look, feel and behave like a standard Linux command line environment. By connecting all this information, toolbx containers lose a certain amount of security gained by using the containers technology. Therefore, you should not treat toolbx 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 toolbx from inside toolbx containers.

Installation

Fedora Sway Atomic

Toolbx is preinstalled on Fedora Sway Atomic.

Your first toolbox

Once toolbx is installed, two simple commands are required to get started:

$ toolbox create

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

$ toolbox enter

Once inside the toolbox, you can access common command line tools, and install new ones using a package manager (e.g., DNF on Fedora).

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

Commands and usage

toolbox create [options] <name>

Creates a toolbx 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.

To use a specific version of the host system (e.g., Fedora 32 on Fedora 34), use the --release <release> | -r <release> option.

To use a different distribution to create a toolbx container (e.g., RHEL on Fedora), use the --distro <distro> | -d <distro> option.

To use a different image, use the --image <name> | -i <name> option.

toolbox enter [options] <name>

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

To enter a toolbox with specific name, use the name argument.

To enter a toolbox for a different distribution (e.g., Fedora on RHEL), use the --distro <distro> |-d <distro> option.

To enter a toolbox with specific version (e.g., RHEL 8.1 on RHEL 8.3), use the --release <release> | -r <release> option.

toolbox run [options] <cmd> <arg …​>

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

To run a command in a toolbox with specific name, use the --container <name> | -c <name> option.

To run a command in a toolbox for a different distribution (e.g., Fedora on RHEL), use the --distro <distro> |-d <distro> option.

To run a command in a toolbox with specific version (e.g., RHEL 8.1 on RHEL 8.3), use the --release <release> | -r <release> option.

toolbox list [options]

Lists local toolbx images and containers.

To only show containers, use the --containers | -c option.

To only show images, use the --images | -i option.

toolbox rm [options] <name …​>

Removes one or more toolbx containers.

The --force | -f option removes the marked containers even if they are running.

The --all | -a option removes all toolbx containers.

toolbox rmi [options] <name …​>

Removes one or more toolbx images.

The --force | -f option removes the marked images and all containers that have been created using the marked images.

The --all | -a option removes all toolbx images.

toolbox --help

Shows Toolbx’s manual page.

Exiting a toolbox

To return to the host environment, either run exit or quit the current shell (typically Ctrl+D).

Under the hood

Toolbx uses the following technologies:

Contact and issues

To report issues, make suggestions, or contribute fixes, see toolbx’s GitHub project.

To get in touch with toolbx users and developers, use Fedora’s Discourse instance, or join the #silverblue IRC channel on Libera.