-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offer a better way to visually distinguish between containers #98
Comments
Well, I see there are envvars
defined. |
Yes, I agree that this is a genuine problem. |
Around hostname in the toolbox, I miss my machine hostname. Also, I suppose that if I start using silverblue on my servers (which will be the case when upgrading from CoreOS), I might get confused when seeing the prompt with just |
May I suggest that the default hostname should be composed of the machine hostname and the toolbox name ? For example, I run multiple toolboxes (gui, wine, dev, ...) and I have several computers (laptop, server, ...). The toolbox hostname could be a composition of both such as: In the meantime, I created an init script that executes when the shell starts: if [[ "$(hostname)" = toolbox ]] && [[ "$(cat /etc/hostname)" != toolbox ]]; then
hostname="$(cat /etc/hostname)"
sh="$SHELL"
if ! [[ -e "$sh" ]]; then
sh=/bin/bash
fi
echo "Changing hostname from toolbox to $hostname and re-executing $sh..."
sudo hostname "$hostname" && exec "$sh"
fi |
Since there is already a way to name containers on podman level with @@ -1079,7 +1079,7 @@ create()
--dns none \
--env TOOLBOX_PATH="$TOOLBOX_PATH" \
--group-add "$group_for_sudo" \
- --hostname toolbox \
+ --hostname ${toolbox_container//_/-} \
--ipc host \
--label "com.github.containers.toolbox=true" \
--label "com.github.debarshiray.toolbox=true" \ We can also allow overriding this name (#210), but I don't see why this would be necessary with adequate default. |
..to distinguish different toolboxes more easily inside a toolbox. Replace underscores with dashes since underscores are not allowed in hostnames. Fixes: containers#98, containers#120 Signed-off-by: Ievgen Popovych <jmennius@gmail.com>
..to distinguish different toolboxes more easily inside a toolbox, this includes version information too (by default). Replace underscores with dashes since underscores are not allowed in hostnames. Fixes: containers#98, containers#120 Signed-off-by: Ievgen Popovych <jmennius@gmail.com>
..to distinguish different toolboxes more easily inside a toolbox, this includes version information too (by default). Replace underscores with dashes since underscores are not allowed in hostnames. Fixes: containers#98, containers#120 Signed-off-by: Ievgen Popovych <jmennius@gmail.com>
I've been using #383 which is a good place to start... ;) Since I use Zsh with powerlevel10k theme - I decided to implement a simple toolbox indication for p10k which would include the toolbox hexagon and container name, it looks like that: At this point, I've come to realize that when taken to this level, the hostname will be a limitation (doesn't allow underscores, semicolons, etc) and wouldn't allow seeing the actual hostname in the shell too (see comment). What we should do instead is provide all the toolbox metadata in some standardized format inside a container. Please share your thoughts. |
@Jmennius I think it'd be great to expose environment variables like that versus taking over the hostname. That also provides more flexibility for people with custom prompts that may not even display the hostname. |
I think we should actually create a new issue, with proper name and description (with regards to environment variables), and close this one in its favor (ff maintainers actually agree with us 😄 ) @HarryMichal your take? Should we aim to use special environment variables instead of fiddling with the hostname? See my comment. |
I'm wondering how to go around this. Adding just the OS version to the hostname is the most short-term solution since Toolbox aims to support even other distros. So maybe something in the format of Another thing, Podman does not provide info about the container to the container itself (file I'm also kinda inclined towards adding a |
This is exactly what I am proposing to do - populate some variables that we can use inside of the toolbox. I think it is inferior to have stuff automatically put into either hostname or container name, it should be all up to the user. Regarding #383, yes, this is more of a temporary solution in my opinion. |
Yes, #969 has some good suggestions in this direction.
Yes, a start-up script is a way to hack around this.
By the way, looking for the existence of |
Yeah. :/
Yeah. We might need a
Go for it! :) I think the end goal would be to convince distributions to make their default shell prompts Toolbx aware, so that the prompt changes as necessary inside a container. Or, we could also hack something up using |
I forgot to ask ... What's that |
I see that it got done in Powerlevel10k already. /me is still catching up |
Well, The problem with using
That's #563 |
#969 has some good ideas on how to chose a better default for the container's host name. It's not going to solve everything, but it's still going to be an improvement, and we have a clear way ahead, so let's focus on that first. Baby steps. :) |
I am going to close this issue in favour of #969 so that the list of open issues doesn't balloon out of control, and continues to roughly reflect the items that are on the current to-do list. However, it will still be around for future reference. |
On second thoughts, there are two different high level items here. One is to improve the default hostname which is important for various technical reasons and that's what #969 is about. The second is about offering a better way to visually distinguishing one Toolbx container from another. As @Jmennius and others have pointed out, that can also be done by customizing the shell's prompt by using the metadata from Reopening. |
Ah, that's an option to only enter the container 'once' (since I do not want all tabs to be in a container by default) - just disables terminal container tracking, see #384. |
imo setting the container hostname to a custom script that changes the prompt would mean that regular this is also the approach taken by distrobox - which has risen in popularity in the community so having the behaviour be compatible seems beneficial. sample output from distrobox:
|
I recently came across this problem again when I was using a f36 and f38 toolbox in parallel for a while, and it was very hard to figure out what was what, since I don't set up any custom prompts or bling out my shell. I think the goal for this issue should be to make the default experience in this case non-confusing. |
I created a new toolbox name fedora-develop-37 and install all the 'dev tools' I would need to do rustlang development. Also install ZSH, TMUX, Oh-My-ZSH, and Powerlevel10k and Powerline bindings in TMUX. To my surprise, the toolbox name is in the Prompt of Powerlevel10k I have another toolbox, name fedora-toolbox-37 and the name does not show up, just the 'tool icon' I wonder which package is reporting the toolbox hostname to Powerlevel10k segment in the fedora-develop-37 so I can install it in the regular fedora-toolbox-37 container, so it shows there also? https://ask.fedoraproject.org/t/name-of-toolbox-showing-in-powerlevel10k-prompt/31590 |
I don't want to sound disrespectful but the fact that simple feature requests/bugs sit stale for months doesn't speak well to the general state of this project. ;-( |
I took a quick look into the theme's source and the code that figures out the toolbox name is here: It reads This may be a workaround until #1086 is merged. |
I personally don't care too much about the hostname itself particularly, but I think the only thing that makes sense is to have the container name appear in prompts by default (even my original suggestion of This is really not that hard, right? Let's just do it? |
I imagine one can run
If The actual lines of bash code that I rely on for this starts at https://github.com/castedo/cnest/blob/cnest-2.1-2/bin/create-cnest#L72 The key observation here is that
|
Regarding messing with the hostname, for a generic tool that I assume should work well with lots of different applications, I recommend against setting the hostname to something other than the host hostname if the container shares the network. distrobox was doing that and it causes enough problems they changed it. There's a lot more discussion and detail here: For most apps it's probably not an issue. I went years messing with the hostname for the sake of tweaking the prompt, and never had a problem, but I only use CLI tools in my containers. |
It could be nice if the toolbox container hostname included the OS release version.
If one is running multiple toolbox releases it could be confusing which is which.
Maybe could use
toolbox:30
etc. Well this is just a suggestion.The text was updated successfully, but these errors were encountered: