I ran into the same issue on a Hetzner IPv6 only machine. The reason for the error seems to be, that ghcr.io does not provide an IPv6 AAAA DNS record. There is an open issue from November 2023 mentioning it.
I personally solved the issue by using a different image registry, in my case DockerHub, which allows to freely host public images.