You are not logged in.

#1 2022-04-15 14:51:03

Baumfaust
Member
Registered: 2022-04-15
Posts: 2

No internet connection inside docker container

I have 2 arch linux computers, docker is installed on both. However, on the second one I have the problem that the running container can not connect to the internet. At least not via domain names, but pinging IPs directly works.

Computer 1

docker run alpine ping  www.google. com

=> works fine

Computer 2

docker run alpine ping  www.google. com

  => ping: bad address 'www.google.com'

When I pass the --dns parameter it works fine too for PC 2


docker run --dns=8.8.8.8 alpine ping  www.google. com

Both are using a wired connection to a Fritz Box configured in

/etc/systemd/network/wired.network

Computer 1

[Match]
Name=enp0s25

[Network]
Address=192.168.178.3/24
Gateway=192.168.178.1
DNS=192.168.178.1
#DHCP=yes
IPForward=yes

[Link]
WakeOnLan=magic

Computer 2

[Match]
Name=enp1s0

[Network]
Address=192.168.178.2/24
Gateway=192.168.178.1
DNS=192.168.178.1
#DHCP=yes
IPForward=yes

[Link]
WakeOnLan=magic

Pinging www.google.com from machines direktly works fine on both.

Does anyone have a idea, why I have to use the DNS flag on computer 2?

Offline

#2 2022-04-20 03:50:12

Thor-x86
Member
From: Java Island, Indonesia
Registered: 2021-10-15
Posts: 15
Website

Re: No internet connection inside docker container

Inside the container, run "cat /etc/resolv.conf" to make sure it's not musl related problem


Stay curious,
Eric
--------------------------------------------------------------------------------
Mail | PGP Key | GitHub

Offline

#3 2022-04-20 15:02:51

Baumfaust
Member
Registered: 2022-04-15
Posts: 2

Re: No internet connection inside docker container

Thanks that was the reason, Computer 2 had a bad IP configured in etc/resolv.conf.
I now installed openresolv, generated a new config using resolvconf -u and edited my router's IP.

#
# /etc/resolv.conf
#

#search <yourdomain.tld>
nameserver 192.168.178.1

# End of file

Now everything works fine.

Offline

#4 2022-04-21 18:49:14

Thor-x86
Member
From: Java Island, Indonesia
Registered: 2021-10-15
Posts: 15
Website

Re: No internet connection inside docker container

Baumfaust wrote:

Thanks that was the reason...

Glad it helps smile


Stay curious,
Eric
--------------------------------------------------------------------------------
Mail | PGP Key | GitHub

Offline

Board footer

Powered by FluxBB