distrobox icon indicating copy to clipboard operation
distrobox copied to clipboard

Default to use a different home directory

Open secretmango opened this issue 1 year ago β€’ 14 comments

Distrobox is great in that it even has this ability, unlike toolbox.

But it is opt-in and kinda hidden and manual, meaning 90% of people will not use it.

It is extremely important to separate dotfiles from each other, so the only good way to do that is using a different homedir.

Otherwise, using a different Distro, or a newer or older version of programs or simply the same in a container and on the host, can result in extreme breakages.

Its basically a ticking bomb, when these dotfiles will clash.

I would propose to create a directory ~/distrobox/ and in there one with the boxname or if NULL the image name and use that by default.

The benefits of sharing a homedir are naive and can be accomplished by symlinking the needed files or directories.

secretmango avatar Mar 23 '24 00:03 secretmango

You mean the functionality of --HOME path/to should be default and therefore a required arg, and a --SHARE_CURRENT_HOME path/to should be created as a option instead?

paul-hammant avatar Apr 16 '24 10:04 paul-hammant

hm, yes, by default the home should be in $HOME/distrobox/$BOXNAME.

I dont think a path is needed when sharing the current home, so distrobox create --use-host-home NAME would be sufficient.

secretmango avatar Apr 16 '24 12:04 secretmango

I think you're right - a default to a predictable directory within the user's current $HOME (and informed as such in the output) Overidable by:

  1. --home as I said a few hours ago
  2. --share-current-home

I can't get --home working at all presently. I must be doing something wrong.

paul-hammant avatar Apr 16 '24 14:04 paul-hammant

no I use --home now all the time, successfully.

secretmango avatar Apr 17 '24 20:04 secretmango

I might uninstall podman and install docker to test again.

paul-hammant avatar Apr 17 '24 20:04 paul-hammant

no I use podman on Fedora 39 Kinoite without issues.

mkdir ~/Distrobox

distrobox-create Tests --home ~/Distrobox/Tests

secretmango avatar Apr 17 '24 20:04 secretmango

And as you enter it and do pwd and ls its the dir you expect and empty?

paul-hammant avatar Apr 17 '24 21:04 paul-hammant

I dont know, but cd ~ goes into that directory, which means that it worked!

secretmango avatar Apr 17 '24 21:04 secretmango

Me on Chromebook (Debian 12):

paul@penguin:~$ mkdir ~/Distrobox

distrobox-create Tests --home ~/Distrobox/Tests
Image registry.fedoraproject.org/fedora-toolbox:39 not found.
Do you want to pull the image now? [Y/n]: Y
Trying to pull registry.fedoraproject.org/fedora-toolbox:39...
Getting image source signatures
Copying blob 544ab65c4027 done  
Copying config 841c1b7297 done  
Writing manifest to image destination
Storing signatures
841c1b7297c9e8bfc291b0206288f0697053c010564bcc4da626e2d7babece10
Creating 'Tests' using image registry.fedoraproject.org/fedora-toolbox:39       Resource limits are not supported and ignored on cgroups V1 rootless systems
 [ OK ]
Distrobox 'Tests' successfully created.
To enter, run:

distrobox enter Tests

paul@penguin:~$ distrobox enter Tests
Starting container...                            [ OK ]
Installing basic packages...                     [ OK ]
Setting up devpts mounts...                      [ OK ]
Setting up read-only mounts...                   [ OK ]
Setting up read-write mounts...                  [ OK ]
Setting up host's sockets integration...         [ OK ]
Integrating host's themes, icons, fonts...       [ OK ]
Setting up package manager exceptions...         [ OK ]
Setting up rpm exceptions...                     [ OK ]
Setting up distrobox profile...                  [ OK ]
Setting up sudo...                               [ OK ]
Setting up user groups...                        [ OK ]
Setting up kerberos integration...               [ OK ]
Setting up user's group list...                  [ OK ]
Setting up existing user...                      [ OK ]
Setting up user home...                          [ OK ]
Ensuring user's access...                        [ OK ]
Setting up skel...                               [ OK ]

Container Setup Complete!
πŸ“¦[paul@Tests paul]$ pwd
/home/paul
πŸ“¦[paul@Tests paul]$ ls 
Desktop  Distrobox  Downloads  fleet  gems  pve_mounts.sh  scm  sshfs  WebstormProjects
πŸ“¦[paul@Tests paul]$ exit
logout
paul@penguin:~$ distrobox --version 
distrobox: 1.7.1.0

It looks to have ignored the --home directive

Me on Ubuntu 22.04 on a NUC:

paul@paul-nuclin:~$ mkdir ~/Distrobox

distrobox-create Tests --home ~/Distrobox/Tests
Image registry.fedoraproject.org/fedora-toolbox:39 not found.
Do you want to pull the image now? [Y/n]: Y
Trying to pull registry.fedoraproject.org/fedora-toolbox:39...
Getting image source signatures
Copying blob 544ab65c4027 done  
Copying config 841c1b7297 done  
Writing manifest to image destination
Storing signatures
841c1b7297c9e8bfc291b0206288f0697053c010564bcc4da626e2d7babece10
Creating 'Tests' using image registry.fedoraproject.org/fedora-toolbox:39	 [ OK ]
Distrobox 'Tests' successfully created.
To enter, run:

distrobox enter Tests

paul@paul-nuclin:~$ distrobox enter Tests
Starting container...                   	 [ OK ]
Installing basic packages...            	 [ OK ]
Setting up devpts mounts...             	 [ OK ]
Setting up read-only mounts...          	 [ OK ]
Setting up read-write mounts...         	 [ OK ]
Setting up host's sockets integration...	 [ OK ]
Integrating host's themes, icons, fonts...	 [ OK ]
Setting up package manager exceptions...	 [ OK ]
Setting up rpm exceptions...            	 [ OK ]
Setting up distrobox profile...         	 [ OK ]
Setting up sudo...                      	 [ OK ]
Setting up user groups...               	 [ OK ]
Setting up kerberos integration...      	 [ OK ]
Setting up user's group list...         	 [ OK ]
Setting up existing user...             	 [ OK ]
Setting up user home...                 	 [ OK ]
Ensuring user's access...               	 [ OK ]
Setting up skel...                      	 [ OK ]

Container Setup Complete!
πŸ“¦[paul@Tests paul]$ pwd
/home/paul
πŸ“¦[paul@Tests paul]$ ls
 debian-12.qcow2   Public    Desktop           flasktest        pve_mounts.sh     snap
 bin           Distrobox         PycharmProjects   sshfs
 Documents          Music        Downloads         graffle.txt            Notepad++.desktop        Pictures          Videos
πŸ“¦[paul@Tests paul]$ exit
logout
paul@paul-nuclin:~$ distrobox --version
distrobox: 1.7.1.0

Seems to have ignore --home too.

If you're on an older version of distrobox, maybe that's the difference

paul-hammant avatar Apr 18 '24 09:04 paul-hammant

did you do a cd ~ ? If the home is correctly set, or if the user automatically moves to that directory are 2 different things.

And why does Distrobox create a Fedora container on Debian??

secretmango avatar Apr 18 '24 12:04 secretmango

$ distrobox enter Tests
πŸ“¦[paul@Tests paul]$ ls 
Desktop  Distrobox  Downloads  fleet  gems  pve_mounts.sh  scm  sshfs  WebstormProjects
πŸ“¦[paul@Tests paul]$ cd ~
πŸ“¦[paul@Tests ~]$ ls 
πŸ“¦[paul@Tests ~]$ 

Well you learn something new every day. I'm not in my home directory by default on "enter"?

paul-hammant avatar Apr 18 '24 12:04 paul-hammant

well this may be a missing feature but actually helps here, as the separate home dir is unobtrusive ;D

secretmango avatar Apr 18 '24 13:04 secretmango

There is an environment variable which you can set which will place all distroboxes' homes into their respective folders. DBX_CONTAINER_HOME_PREFIX is meant to be a folder. If you set it then your distrobox named test will have its home folder located in $DBX_CONTAINER_HOME_PREFIX/test.

misobarisic avatar Apr 20 '24 12:04 misobarisic

I don't think distrobox is for me. I wanted to have as simple way of making a linux guest that was fully file-system isolated from the host, and I don't think that can be done. Sorry for wasting everyone's time

paul-hammant avatar Apr 21 '24 12:04 paul-hammant

@misobarisic is right, DBX_CONTAINER_HOME_PREFIX will default all the containers to a custom HOME

@paul-hammant if you're searching for something isolated, yes, distrobox is not for you, this is not in scope with the project

89luca89 avatar May 01 '24 10:05 89luca89

@misobarisic okay so I would use DBX_CONTAINER_HOME_PREFIX=distrobox to place all boxes in $HOME/distrobox/name ?

Is there a good way to set the environment variable permanently?

other than sudo echo "DBX_CONTAINER_HOME_PREFIX=distrobox" >> /etc/environment ?

I dont know much about this but it doesnt feel right to set this variable for all apps.

boredsquirrel avatar May 09 '24 20:05 boredsquirrel

@boredsquirrel I use the config file, see: https://github.com/89luca89/distrobox#configure-distrobox

archerallstars avatar May 09 '24 21:05 archerallstars

@archerallstars thanks for solving the issue!

So... for sure this could be added by distros. But do you all agree that sharing the dotfiles is a huge problem? Imagine running an Ubuntu container on Fedora. You may have the same software, different versions, different tweaks. These will overwrite their dotfiles and cause breakages.

I would very much appreciate having this value set by default. Otherwise Distrobox can not be seen as "well the apps can access your files but they run isolated" as they can literally break the host system.

secretmango avatar May 09 '24 22:05 secretmango

The container_user_custom_home key in the config file is a way to achieve "guest apps in distrobox containers CANNOT access your host files AND they run isolated"?

paul-hammant avatar May 10 '24 11:05 paul-hammant

not sure if I understand your comment

secretmango avatar May 12 '24 13:05 secretmango