Toolbox: how to use a custom home directory per box?

I am thinking about switching from Distrobox to Toolbox, as it is faster and more minimal.

But the biggest feature of Distrobox I miss is using a different home dir per container, automatically.

~ ❯❯❯ cat /etc/distrobox/distrobox.conf

When creating a box it will automatically use ~/distrobox/BOXNAME as homedir. This prevents dotfile issues, especially when using different distros in the box than on the host.

Is this possible for Toolbox?


Note: this is only one issue I have with Toolbox vs Distrobox.

  • Distrobox has a shortcut for updating all containers using their individual package managers
  • while the binary export may be strange, the app export works really well and is really not complex
  • distrobox allows distrobox assemble to build a container with a containerfile
  • toolbox said “my container image is too old” when it didnt recognize its id. Like… hardcoded breakage? This was ublue-distrobox and updated yesterday

Also, the biggest issue with real usage for installing apps is: there is no normal way to upgrade the distro, so you need to use a rolling release or rebuild the container.

i’m not going to post the Github thread where I brought this up 5yrs ag. . .

If you find me in there screaming and shouting, just know. . . It was a long time ago. :upside_down_face:

There was a fork in tlbx also had similar issues. . . But I think they solved it :thinking:

Here’s one more. . .

So from an earlier project I have/had here on the forums :

I came up with a kind of “workaround” where you essentially need to build an image :

# Use the Fedora 40 base image
FROM fedora:latest

# Create a new user 'user' with a custom home directory and a unique UID
RUN useradd -m -d /home/USER/Project/Podman_Containers/thorium/user -u 2000 user

# Set the new user's home directory
ENV HOME=/home/USER/Project/Podman_Containers/thorium/user
USER user
WORKDIR /home/USER/Project/Podman_Containers/thorium/user

# Install any necessary packages
RUN sudo dnf -y install sudo

It’s been a few months since I last tried, but I could show you the scripts if I can dig them up, and show more things like setting the SELinux sandbox_web_t as well.

1 Like

Here is an image of the toolbox with a different /home dir.

Here is me playing a YouTube video and the sound works. . .

Dockerfile to run Thorium Browser in a toolbox Container with a different /home :

# Use the Fedora 40 base image
FROM fedora:40

# Create a new user 'user' with a custom home directory and a unique UID
RUN useradd -m -d /home/$USER/Project/Podman_Containers/thorium/user -u 2000 user

# Set the new user's home directory
ENV HOME=/home/$USER/Project/Podman_Containers/thorium/user

# Install sudo and configure passwordless sudo for the user
RUN dnf -y install sudo && \
    echo 'user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Create necessary directories with correct permissions
RUN mkdir -p /home/$USER/Project/Podman_Containers/thorium/user/.config /home/$USER/Project/Podman_Containers/thorium/user/.local && \
    chown -R user:user /home/$USER/Project/Podman_Containers/thorium/user

# Switch to the new user
USER user

# Set the working directory
WORKDIR /home/$USER/Project/Podman_Containers/thorium/user

# Copy Thorium browser RPM file into the container
COPY thorium-browser_124.0.6367.218_AVX2.rpm .

# Install Thorium browser from RPM
RUN sudo dnf -y install ./thorium-browser_124.0.6367.218_AVX2.rpm

# Optionally set entrypoint or default command if needed
# ENTRYPOINT ["thorium-browser"]

I got permission errors that were easily fixed :

mkdir: cannot create directory ‘/home/$USER/Project/Podman_Containers/thorium/user/.config’: Permission denied
touch: cannot touch '/home/$USER/Project/Podman_Containers/thorium/user/.config/toolbox/toolbox-welcome-shown': No such file or directory

by simply : sudo chown -R $USER:$USER /home/$USER/Project/Podman_Containers/thorium/user

So now Thorium’s image runs in a different home. This is a far less elegant solution than DistroBox but if you need to do stuff in toolbox, here ya’ go ! :fedora:

This has come up in the past with the toolbox project; see Separate home directories for each toolbox · Issue #1044 · containers/toolbox · GitHub and Isolated development environments to fend against bugs and malware in code under development, hygiene, etc. · Issue #183 · containers/toolbox · GitHub

cc: @rishi


Added bug-reported

thanks, the issue is marked as fixed but not fixed.

1 Like

Just one last thing, here is anaconda-navigator running in it’s own /home inside a toolbox container.

:fedora: :100: :party:

“faster” as in “initial setup is faster”, and “minimal” referring to image size? Both come from the fact that distrobox uses non-specialized images. But note that you can use specialized toolbox images with distrobox.

Thanks for the tip regarding DBX_CONTAINER_HOME_PREFIX in config. That’s easily overlooked in doc.

I have no hopes whatsoever in toolbox incorporating this much requested feature. Maintainers apparently don’t want it, and the switch from bash to go does not quite increase the contributor base.

On the other hand, I have no idea how you would use foo-box for testing or isolating development environments if you cannot separate homedirs. It seems as if toolbox’s only purpose is to work around the limitations of atomic desktops, whereas distrobox tries to unleash the full potential of this concept.

1 Like


Pretty much. . . The moment you need isolated environments, you’re back to looking for alternatives.

1 Like