Skip to content
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

Show hostname when inside containers too #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

edwintorok
Copy link

distrobox (and other toolbox-like containers) set a hostname, and it is useful to be able to distinguish whether you are inside the container or outside.
When /run/.containerenv is present then show the hostname, just as if it was an SSH-ed remote host.

`distrobox` (and other toolbox-like containers) set a hostname,
and it is useful to be able to distinguish whether you are inside the
container or outside.
When /run/.containerenv is present then show the hostname, just as if it
was an SSH-ed remote host.

Signed-off-by: Edwin Török <edwin@etorok.net>
@agkozak agkozak self-assigned this Jan 3, 2023
@agkozak
Copy link
Owner

agkozak commented Jan 17, 2023

It looks as if docker creates, not /run/.containerenv, but /.dockerenv, so we would want to update that test to

if _agkozak_is_ssh || (( EUID == 0 )) || [[ -f /.dockerenv || -f /run/.containerenv ]]; then

Perhaps you could confirm that that is the case? I don't use distrobox, but that was a problem I ran into when I tried it out.

Your idea looks very clever to me. Give me a while to think if there are any downsides to using it, OK? Thanks so much.

@lfromanini
Copy link

I just opened an issue before checking this pull request, but I think it contemplates this subject. Please, check, if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants