Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3552

General discussion • Docker intermittently uses IPv6 despite disabling IPv6 system-wide on Raspberry Pi

$
0
0
Hi everyone,

I'm running Docker on a Raspberry Pi 4 (8GB model) with Raspberry Pi OS, and I’m facing an issue where Docker intermittently attempts to use IPv6 addresses to connect to Docker Hub, even though I've disabled IPv6 both system-wide and within Docker's configuration. Below are the steps I’ve taken so far to enforce IPv4 usage and disable IPv6:

System Configuration:

IPv6 Disabled at Kernel Level:
- I modified

Code:

/boot/firmware/cmdline.txt
to include

Code:

ipv6.disable=1
:

Code:

console=serial0,115200 console=tty1 root=PARTUUID=fabab7a4-02 rootfstype=ext4 fsck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles cfg80211.ieee80211_regdom=IN ipv6.disable=1

- Verified with

Code:

ip -6 addr show
, which shows no IPv6 addresses.

Docker Daemon Configuration:
- Edited

Code:

/etc/docker/daemon.json
to disable IPv6 and set IPv4 DNS servers:

Code:

 {     "ipv6": false,     "dns": ["8.8.8.8", "8.8.4.4"]  }
Docker Service Environment Overrides:
- Created override file

Code:

/etc/systemd/system/docker.service.d/override.conf
with the following settings:

Code:

[Service]  Environment="DOCKER_OPTS=--dns=8.8.8.8 --dns=8.8.4.4 --ipv6=false"  Environment="GODEBUG=netdns=go+2"

- Reloaded and restarted Docker using:

Code:

sudo systemctl daemon-reload  sudo systemctl restart docker
NetworkManager Configuration:
- Configured

Code:

/etc/NetworkManager/NetworkManager.conf
with:

Code:

[main]  dns=none  [connection]  ipv6.method=ignore

- Restarted NetworkManager:

Code:

sudo systemctl restart NetworkManager
iptables Rules to Block IPv6:
- Set up rules to drop all IPv6 traffic:

Code:

sudo ip6tables -P INPUT DROP  sudo ip6tables -P FORWARD DROP  sudo ip6tables -P OUTPUT DROP

- Saved rules using

Code:

iptables-persistent
.

The Issue:
Despite all these configurations, Docker still sometimes attempts to resolve registry URLs using IPv6, resulting in errors like:

Code:

docker: Error response from daemon: Head "https://registry-1.docker.io/v2/library/hello-world/manifests/latest": Get "https://auth.docker.io/token?scope=repository%3Alibrary%2Fhello-world%3Apull&service=registry.docker.io": dial tcp [2600:1f18:2148:bc01:20a3:9c3e:d4a7:9fb]:443: socket: address family not supported by protocol.
Additional Observations:
- The first attempt to pull an image after a restart often succeeds, but subsequent attempts fail.
- I have verified that IPv6 is not assigned to any network interfaces (

Code:

ifconfig eth0
shows only IPv4 addresses).
- Entries in

Code:

/etc/hosts
map Docker registry domains to known IPv4 addresses.

My Question:
What else could be causing Docker to intermittently use IPv6 despite these configurations? Are there any Docker-specific or system-level settings that I might have overlooked that could force IPv4 consistently? Any insights or suggestions would be greatly appreciated!

Thanks in advance!

Statistics: Posted by fsl4faisal — Fri Sep 13, 2024 3:31 am



Viewing all articles
Browse latest Browse all 3552

Trending Articles