Comments (4)
I think this is partially a typo/error in the init-hook
provided in the documentation: https://github.com/89luca89/distrobox/blob/main/docs/useful_tips.md#enable-ssh-x-forwarding-when-ssh-ing-in-a-distrobox
I think command substitution here is misplaced, uname -n
already prints to stdout and can be redirected directly. Or you can use echo
on the provided command. I.e.
uname -n > /etc/hostname
echo "$(uname -n)" > /etc/hostname
Tested on Fedora 39 below:
# Also tested the 'echo "$(uname -n)" > /etc/hostname' with the same result
user@hostname $ distrobox create --image ghcr.io/username/sample-image:latest -n box-name \
--init-hooks 'uname -n > /etc/hostname' && distrobox enter box-name
...
Setting up groups... [ OK ]
Setting up users... [ OK ]
Setting up skel... [ OK ]
Executing init hooks... [ OK ]
Container Setup Complete!
[email protected] $ cat /etc/hostname
box-name.hostname
[email protected] $ hostname
box-name.hostname
It works! Sort of? For reasons that may make sense but are beyond me at the moment, the resulting hostname is a FQDN (the container name as a subdomain of the hostname).
What I mean is, I would rather expect the outcome of uname -n > /etc/hostname
to be:
[email protected] $ cat /etc/hostname
hostname
from distrobox.
In the time since making that comment I've come to thinking/realizing a few things:
(1) It's probably fine that the result of this init-hook
method creates a new FQDN for the intents and purposes of both resolving to the host name and being unique/individually identifiable on a local network (i.e. there's nothing wrong with boxname.hostname
).
It turns out there's already been quite a lot of discussion about this in this repo and in toolbox which I only skimmed, but the important parts seem to work (e.g. ssh -x forwarding) in this scheme.
(2) The documentation has a typo, which is a separate issue that I also had run into when trying this out (which is why I knew the fix). I've made a pull request to address this here.
(3) OP floated the idea of having a --hostname
parameter rather thatn using init-hook
which seems like a reasonable feature, e.g. docker-compose
has this. There may already be a feature request tracking this if you look.
from distrobox.
-
boxname.hostname
is the hostname that is set in the container by default. I saw the other issues that talked about hostname setting, that's where I got some of my attempted solutions. -
The
--hostname
flag is what distrobox uses to tell podman/docker what hostname to set in the container (boxname.hostname
by default).
In fact I ended up solving the issue using that flag. I replaced the distrobox.ini
file I was using during the creating of my container with a script that overrides the --hostname
flag distrobox passes into the container runner.
distrobox rm env --force;
distrobox create --image docker.io/briandipalma/env:latest \
--name env \
--pull \
--additional-flags "--hostname ${HOSTNAME}" \
--pre-init-hooks "SHELL=/usr/bin/fish";
distrobox enter env;
I'll close the issue as I've a solution that I'm happy with.
from distrobox.
In fact I ended up solving the issue using that flag. I replaced the
distrobox.ini
file I was using during the creating of my container with a script that overrides the--hostname
flag distrobox passes into the container runner.
I have additional_flags="--hostname <sub.domain>"
I ended up in this issue because I was looking for a way to use command substitution in init_hooks
. To bootstrap my devbox, I use sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $HOME/.local/bin
. This fails with the error tmpdir: parameter not set
.
This is probably the culprit, sort of. I'm not sure how tmpdir
is unset because the variable does get set.
I thought perhaps it's because mktemp
might be missing. Try adding additional_packages=coreutils
or init_hooks="sudo dnf install -y coreutils"
(or pre_init_hooks
). Still breaks.
Take the command substitution out.
init_hooks="curl -sSLf get.chezmoi.io -o chezmoi-installer;"
init_hooks="chmod +x ./chezmoi-installer;"
init_hooks='./chezmoi-installer -b "/home/redbeardymcgee/devbox/.local/bin" init redbeardymcgee --ssh --apply --promptDefaults --force;'
Creating './chezmoi-installer -b " ${init_hooks}' using image registry.fedoraproject.org/fedora-toolbox:latest /home/josh/.local/bin/distrobox-create: 1: eval: init_hooks: parameter not set
Huh?
from distrobox.
Related Issues (20)
- Debian 12 box, Wine, DualSense gamepad "Failed to get device that has changed" HOT 1
- Phantom container named NAME when performing operations with --all HOT 3
- [Error] No such file or directory when path contains "at" (@) character
- Arch Distrobox bricking itself on NixOS and won't compile Cargo packages [Error] HOT 2
- Installing basic packages... Error: An error occurred; ubuntu 23.10 (both host and distrobox image) HOT 1
- GUIs crash when conected to the Internet HOT 1
- Containers distros supports Slackware 15
- [Suggestion] Blackarch toolbox image
- [Error] Unable to start rootless container created by distrobox with podman and runc v1.2.0~rc1
- [Error] distrobox enter fails if Username has "\" in name
- [QUESTION] How to run an entire desktop environment from distrobox
- shell prompt no longer differentiates when inside container HOT 1
- /home/USER/.local/bin/distrobox-create: 1: eval: tmpdir: parameter not set HOT 2
- [Error] Distrobox container created itโs own password, canโt use sudo. HOT 3
- [Discussion] Chrooting into arm/arm64 environment from distrobox
- Keyboard doesn't work in Ubuntu box
- [Discussion] Ubuntu 24.04 container - ALSA lib pcm_dmix.c:1000:(snd_pcm_dmix_open) unable to open slave HOT 3
- [Error] Cannot enter a void linux container from a void linux host
- Importing display for running mutter.
- Distrobox enter hangs indefinitely upon restarting image HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from distrobox.