So I checked some things. The issue might not be the DNS as resolution works.
apt-get update
Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out
Err:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
Unable to connect to archive.ubuntu.com:http:
Err:3 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
Unable to connect to archive.ubuntu.com:http:
Err:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out
Reading package lists... Done
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease Could not connect to archive.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to archive.ubuntu.com:80 (91.189.88.152), connection timed out
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease Unable to connect to archive.ubuntu.com:http:
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease Unable to connect to archive.ubuntu.com:http:
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease Could not connect to security.ubuntu.com:80 (91.189.88.142), connection timed out Could not connect to security.ubuntu.com:80 (91.189.88.152), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.39), connection timed out Could not connect to security.ubuntu.com:80 (91.189.91.38), connection timed out
W: Some index files failed to download. They have been ignored, or old ones used instead.
This is my iptables where the nextcloud container is 172.17.0.2.
sudo iptables -t nat -L -v
Chain PREROUTING (policy ACCEPT 203 packets, 14092 bytes)
pkts bytes target prot opt in out source destination
2804 169K DOCKER all -- any any anywhere anywhere ADDRTYPE match dst-type LOCAL
Chain INPUT (policy ACCEPT 119 packets, 7001 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 182 packets, 11170 bytes)
pkts bytes target prot opt in out source destination
1279 78907 DOCKER all -- any any anywhere !loopback/8 ADDRTYPE match dst-type LOCAL
Chain POSTROUTING (policy ACCEPT 246 packets, 17025 bytes)
pkts bytes target prot opt in out source destination
18 1080 MASQUERADE all -- any !docker0 172.17.0.0/16 anywhere
0 0 MASQUERADE all -- any !br-8692ab5ba72f 172.16.0.0/24 anywhere
8 516 MASQUERADE all -- any !br-ab3d4919ad39 172.24.0.0/16 anywhere
0 0 MASQUERADE all -- any !br-2bbe458bd139 172.19.0.0/16 anywhere
4 240 MASQUERADE all -- any !br-bcc782403b81 172.16.2.0/24 anywhere
0 0 MASQUERADE all -- any !br-d9cd84d2f643 172.18.0.0/16 anywhere
0 0 MASQUERADE all -- any !br-87db0b73962e 172.20.0.0/16 anywhere
0 0 MASQUERADE tcp -- any any 172.16.2.2 172.16.2.2 tcp dpt:3000
0 0 MASQUERADE tcp -- any any 172.16.0.3 172.16.0.3 tcp dpt:http-alt
0 0 MASQUERADE all -- any br0 10.1.2.0/24 anywhere
0 0 MASQUERADE tcp -- any any 172.17.0.1 172.17.0.1 tcp dpt:https
0 0 MASQUERADE tcp -- any any 172.17.0.2 172.17.0.2 tcp dpt:http
0 0 MASQUERADE tcp -- any any 172.17.0.3 172.17.0.3 tcp dpt:https
0 0 MASQUERADE tcp -- any any 172.17.0.3 172.17.0.3 tcp dpt:http
0 0 MASQUERADE tcp -- any any 172.17.0.4 172.17.0.4 tcp dpt:8777
0 0 MASQUERADE tcp -- any any 172.24.0.3 172.24.0.3 tcp dpt:http
0 0 MASQUERADE udp -- any any 172.24.0.5 172.24.0.5 udp dpt:10000
0 0 MASQUERADE tcp -- any any 172.24.0.5 172.24.0.5 tcp dpt:4443
Chain DOCKER (2 references)
pkts bytes target prot opt in out source destination
0 0 RETURN all -- br-87db0b73962e any anywhere anywhere
0 0 RETURN all -- br-d9cd84d2f643 any anywhere anywhere
21 1342 RETURN all -- br-bcc782403b81 any anywhere anywhere
0 0 RETURN all -- br-2bbe458bd139 any anywhere anywhere
8 504 RETURN all -- br-ab3d4919ad39 any anywhere anywhere
0 0 RETURN all -- br-8692ab5ba72f any anywhere anywhere
1473 88541 RETURN all -- docker0 any anywhere anywhere
0 0 DNAT tcp -- !br-bcc782403b81 any anywhere anywhere tcp dpt:40005 to:172.16.2.2:3000
0 0 DNAT tcp -- !br-8692ab5ba72f any anywhere anywhere tcp dpt:40002 to:172.16.0.3:8080
0 0 DNAT tcp -- !docker0 any anywhere anywhere tcp dpt:5443 to:172.17.0.1:443
0 0 DNAT tcp -- !docker0 any anywhere anywhere tcp dpt:40000 to:172.17.0.2:80
0 0 DNAT tcp -- !docker0 any anywhere anywhere tcp dpt:40003 to:172.17.0.3:443
0 0 DNAT tcp -- !docker0 any anywhere anywhere tcp dpt:40001 to:172.17.0.3:80
0 0 DNAT tcp -- !docker0 any anywhere anywhere tcp dpt:8777 to:172.17.0.4:8777
0 0 DNAT tcp -- !br-ab3d4919ad39 any anywhere anywhere tcp dpt:8888 to:172.24.0.3:80
0 0 DNAT udp -- !br-ab3d4919ad39 any anywhere anywhere udp dpt:10000 to:172.24.0.5:10000
0 0 DNAT tcp -- !br-ab3d4919ad39 any anywhere anywhere tcp dpt:4443 to:172.24.0.5:4443
Any help is appreciated!
Andy