Skip to content

fix: avoid mounting systemd-resolve in unshared netns - #2159

Open
kairosci wants to merge 1 commit into
89luca89:mainfrom
kairosci:fix-unshared-netns-hostname
Open

kairosci wants to merge 1 commit into
89luca89:mainfrom
kairosci:fix-unshared-netns-hostname

Conversation

@kairosci

@kairosci kairosci commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

This PR solves solves the systemd-resolved socket from being mounted when the container uses an isolated network namespace.
Closes #2079

When initializing a container in --unshare-netns mode, we avoid mounting
/run/systemd/resolve. This allows nsswitch to fallback to myhostname
when resolving the container's hostname, fixing an issue where
'hostname -i' fails with 'Unknown host'.

Fixes 89luca89#2079
@balanza
balanza self-requested a review July 17, 2026 09:27
@balanza

balanza commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Hi @kairosci, I've tried the patch on this machine and it's not working

> cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.4 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

> distrobox enter archlinux -- hostname -i
hostname: gethostbyname: Unknown host
2026/07/21 21:48:46 failed to execute enter command: failed to enter the container: error running the interactive command :exit status 1

@kairosci

kairosci commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@balanza I don't know why, but the push didn't push everything even though I literally ran git add ..
In any case, everything should be there now; I tested it again on 24.04 and 26.04, and I can confirm that it works.
Could you test it again as soon as you can? It should work fine now.
Sorry for the inconvenience!

@kairosci

Copy link
Copy Markdown
Contributor Author
distrobox enter test-arch -- hostname -i 2>&1
test-arch
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 ] 
Setting up host's sockets integration...	[ OK ] 
Integrating host's themes, icons, fonts...	[ OK ] 
Setting up distrobox profile...         	[ OK ] 
Setting up sudo...                      	[ OK ] 
Setting up user's group list...         	[ OK ] 
Setting up existing user - shell...     	[ OK ] 
Setting up existing user - groups...    	[ OK ] 
Ensuring user's access...               	[ OK ] 
Container Setup Complete!               	
192.168.1.88

This branch has not been deployed

No deployments
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.

[Error] Unable to look up hostname with ns unshared.

2 participants