Internet from docker container but not from qemu #192

Closed
opened 2025-12-29 00:19:58 +01:00 by adam · 2 comments
Owner

Originally created by @Kiblyn11 on GitHub (May 21, 2021).

Followed initial setup properly.
I tried basic command and I cannot ping or curl internet (works from docker container though).
I found that it works if I add --net=host (which I don't want to).
I don't have a fancy networking configuration.

Start command:

docker run -it \
    --device /dev/kvm \
    -p 50922:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    sickcodes/docker-osx:latest

Logs:

Linux 5.11.16-zen1-1-zen #1 ZEN SMP PREEMPT Wed, 21 Apr 2021 17:22:09 +0000 x86_64 GNU/Linux
:0
1
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/myvg-root  441G  307G  111G  74% /
QEMU emulator version 6.0.0
Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers
libvirtd (libvirt) 7.3.0
               total        used        free      shared  buff/cache   available
Mem:            23Gi       8.4Gi       8.7Gi       865Mi       6.2Gi        13Gi
Swap:           16Gi       643Mi        16Gi
8
16
crw-rw-rw- 1 root kvm 10, 232 May 21 20:20 /dev/kvm
total 0
drwxrwxrwt  2 root root  60 May 21 12:03 .
drwxrwxrwt 19 root root 600 May 21 20:20 ..
srwxrwxrwx  1 root root   0 May 21 12:03 X0
root        1594  0.4  0.2 2938860 56624 ?       Ssl  12:04   2:02 /usr/bin/dockerd -H fd://
user    274439  0.0  0.0   6416  2376 pts/6    S+   20:24   0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox dockerd
747bfa54265d   sickcodes/docker-osx:latest   "/bin/bash -c 'sudo …"   4 minutes ago   Up 4 minutes   0.0.0.0:50922->10022/tcp, :::50922->10022/tcp   cranky_pascal
kvm:x:992:user
docker:x:973:user
libvirt:x:958:user
Originally created by @Kiblyn11 on GitHub (May 21, 2021). Followed initial setup properly. I tried basic command and I cannot ping or curl internet (works from docker container though). I found that it works if I add `--net=host` (which I don't want to). I don't have a fancy networking configuration. Start command: ``` docker run -it \ --device /dev/kvm \ -p 50922:10022 \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e "DISPLAY=${DISPLAY:-:0.0}" \ sickcodes/docker-osx:latest ``` Logs: ``` Linux 5.11.16-zen1-1-zen #1 ZEN SMP PREEMPT Wed, 21 Apr 2021 17:22:09 +0000 x86_64 GNU/Linux :0 1 NAME="Arch Linux" PRETTY_NAME="Arch Linux" Filesystem Size Used Avail Use% Mounted on /dev/mapper/myvg-root 441G 307G 111G 74% / QEMU emulator version 6.0.0 Copyright (c) 2003-2021 Fabrice Bellard and the QEMU Project developers libvirtd (libvirt) 7.3.0 total used free shared buff/cache available Mem: 23Gi 8.4Gi 8.7Gi 865Mi 6.2Gi 13Gi Swap: 16Gi 643Mi 16Gi 8 16 crw-rw-rw- 1 root kvm 10, 232 May 21 20:20 /dev/kvm total 0 drwxrwxrwt 2 root root 60 May 21 12:03 . drwxrwxrwt 19 root root 600 May 21 20:20 .. srwxrwxrwx 1 root root 0 May 21 12:03 X0 root 1594 0.4 0.2 2938860 56624 ? Ssl 12:04 2:02 /usr/bin/dockerd -H fd:// user 274439 0.0 0.0 6416 2376 pts/6 S+ 20:24 0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox dockerd 747bfa54265d sickcodes/docker-osx:latest "/bin/bash -c 'sudo …" 4 minutes ago Up 4 minutes 0.0.0.0:50922->10022/tcp, :::50922->10022/tcp cranky_pascal kvm:x:992:user docker:x:973:user libvirt:x:958:user ```
adam closed this issue 2025-12-29 00:19:58 +01:00
Author
Owner

@Kiblyn11 commented on GitHub (May 21, 2021):

Well in fact it has internet access, just saw the comment about ping not working.
So it can curl http://1.1.1.1, else dns resolution fails.

@Kiblyn11 commented on GitHub (May 21, 2021): Well in fact it has internet access, just saw the comment about ping not working. So it can curl http://1.1.1.1, else dns resolution fails.
Author
Owner

@Kiblyn11 commented on GitHub (May 21, 2021):

Found out that QEMU use only first nameserver declared in /etc/resolv.conf, which is a local resolver I have, so that's why it's not working. (see https://unix.stackexchange.com/questions/614064/why-dns-stops-resolving-under-qemu-user-networking-when-the-host-roams-to-a-pa)

Have been able to fix it by forcing a dns resolver with --dns=1.1.1.1 for instance.

@Kiblyn11 commented on GitHub (May 21, 2021): Found out that QEMU use only first nameserver declared in /etc/resolv.conf, which is a local resolver I have, so that's why it's not working. (see https://unix.stackexchange.com/questions/614064/why-dns-stops-resolving-under-qemu-user-networking-when-the-host-roams-to-a-pa) Have been able to fix it by forcing a dns resolver with `--dns=1.1.1.1` for instance.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Docker-OSX#192