I have rented a VPS Linux VC4-8 server from Strato and would like to deploy a few Docker containers on it.
Unfortunately, the deployed containers do not have internet access or cannot resolve DNS.
As a result, I can't run commands like RUN apk update
in the build process.
I have already tried various solutions, but unfortunately without success. Here are a few threads that I have already read and tried:
https://superuser.com/questions/1130898/no-internet-connection-inside-docker-containers
https://forums.docker.com/t/no-internet-access-in-the-docker-containers/108223
https://askubuntu.com/questions/1445229/no-network-access-from-within-docker-container
The following is an example of my problem starting from a completely clean server (Ubuntu 22.04):
ping 8.8.8.8
or ping google.com
works flawlessly (on the host)
Install Docker using the official instructions (Install using the apt repository)
Run docker pull alpine
and docker run --rm -it alpine:latest
Attach to the alpine Container
PING 8.8.8.8 (8.8.8.8): 56 data bytes
^C
--- 8.8.8.8 ping statistics ---
30 packets transmitted, 0 packets received, 100% packet loss
/ # ping google.com
ping: bad address 'google.com'
I also tried these steps on another server (from Hetzner) and everything worked normally there.
The files, such as /etc/resolv.conf
look almost the same on both servers.
resolv.conf on the Strato Server:
nameserver 127.0.0.53
options edns0 trust-ad
search .
resolv.conf on the Hetzner Server
nameserver 127.0.0.53
options edns0 trust-ad
The default 'bridge' network looks exactly the same when I run docker inspect bridge
.
And when I compare the Container from both machines with docker inspect <container name>
everything looks the same. Only the CgroupnsMode
property is set to host
on the running example and to private
on the Strato Server (but I am not sure if this is a problem regarding the connectivity).
If I start the container with the --network host
option, I can successfully set up the containers and also access the internet from inside the containers, but after that my Django container cannot find the Postgres container. I also think that this is not the preferred way to do this.
Does anyone have any idea what could be the reason that I have these problems with Docker on the Strato server?
I really don't know what else to try.
Thanks in advance for any help!
br, Brian
from the docker forum: https://forums.docker.com/t/docker-bridge-networking-does-not-work-in-ubuntu-22-04/136326/6
The problem is netplan, ubuntu 22.04 use netplan to adress ip via DHCP. You need to modify the file /etc/netplan/50-cloud-init.yaml and add en in front of the * :
network: ethernets: all: dhcp4: true dhcp6: true match: name: 'en*' renderer: networkd version: 2
this will force netplan to use DHCP only on interface en* and the docker interface is docker0
next apply the configuration and restart network:
netplan apply sudo systemctl restart systemd-networkd #Docker need to be restarted to request a new ip sudo systemctl restart docker
Worked for my Strato V-Server with ubuntu 22.04.