Custom Fedora Toolbox Image
图源:LINO - 崩壊3rd繫体字版6周年 108386100
Toolbox can be seen as a wrapper for Podman, aiming to seamlessly integrate containers with the host operating system (Host OS). A similar tool to Toolbox is Distrobox. By sacrificing some container security features (such as port control, resource control, and file isolation), they achieve the following:
- User passthrough: Using the same user and home directory inside the container as the current Host user;
- Device passthrough: Directly accessing the Host’s
/dev
,/media
, etc.; - Network passthrough: Directly using the Host network, providing a network experience identical to the host;
- Service passthrough: By directly utilizing the host’s
/run/user/<uid>
and/tmp
directories along with critical service sockets, it enables access to the host’s display services (X11/Wayland), network services (Avahi), D-Bus, and systemd journal from within the container.
Therefore, Toolbox can be used to:
- Serve as one of the software installation methods for immutable systems. For example, Fedora Silverblue and Fedora CoreOS come pre-installed with Toolbox, while other immutable systems may have Distrobox pre-installed;
- Utilize images from other distributions to seamlessly run programs designed for other distributions within the current one. For instance, running a GUI program that only provides Ubuntu deb packages on Fedora;
- Create a pseudo-root environment when lacking root privileges on the Host. For example, even non-privileged Toolbox containers can use
sudo dnf install
to install software;- The image must have
sudo
package pre-installed, support thesudo
andwheel
groups to obtain root privileges, and enable theNOPASSWD
option;
- The image must have
- Use different versions of images to achieve “running old programs on new systems” or “running new programs on old systems”, or to conduct compatibility testing for programs;
- Customizing the image enables quick and consistent development environment setup;
Create Your Own Toolbox Image
Any OCI-compliant container image can be used with Toolbox. In other words, you can build your own Toolbox image by following standard Docker image building methods.
The Fedora community continuously maintains the Fedora Toolbox image build files at container/fedora-toolbox. Additionally, the community maintains Toolbox images for various mainstream distributions on GitHub at toolbx-images/images.
Taking the Fedora Toolbox image as an example, here is the official Dockerfile example:
1 | # Use fedora:37 instead of fedora-toolbox:37 |
Additionally, three extra files are required: ensure-files
, extra-packages
, and missing-docs
.
To add or remove images in the Toolbox, you can directly modify the extra-packages
file. When making changes, try to ensure that each line contains only the name of one software package. Alternatively, you can follow the [C]
section in the aforementioned Dockerfile to use a custom file without modifying the extra-packages
file.
For example,
1 | COPY added-packages / |
and an example for added-packages
,
1 | nodejs |
Adding Chinese Language Support to Toolbox Images
You can enable and set Chinese as the default display language for command-line/GUI programs within Toolbox by modifying the LANG
variable, regenerating language files, and installing Chinese fonts.
- Add language files: Add the following content before section
[B]
in the above Dockerfile example
1 | # Chinese Language |
- Install fonts and IMEs: Add the following content before section
[C]
or[D]
in the above Dockerfile example
1 |
|
- Set the
LANG
environment variable: Add the following content at the end of the above Dockerfile example
1 | # Set environment variables |
Using Toolbox Images
Taking the custom image tag a.com/fedora-toolbox-customized:37
as an example:
- Pull the custom image using
podman
1 | podman pull a.com/fedora-toolbox-customized:37 |
- Use
toolbox
to create a container
1 | # The container name can be specified arbitrarily |
- Enter the container environment or execute specific programs within the container
1 | # When the host has only one Toolbox container, it will directly enter that container |
Delete Toolbox Container and Image
1 | # Exit all windows currently using Toolbox CLI programs/GUI programs |
Custom Fedora Toolbox Image
https://www.zhouweitong.site/2023/09/14/fedora-toolbox-custom-image-en/