DNS problem? or something else 🤔

hi, this problem is getting me crasy, in several dockers i cant pull the images i need.
however if i try just to ping any url it wil resolve it (from docker and from the host).

 ⚡ root@openmediavault  ~  docker run - -rm curlimages/curl -v https://ghcr.io\~  
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 - -:--:--  0:00:04 --:--:--     0* Could not resolve host: ghcr.io~
* shutting down connection #0
curl: (6) Could not resolve host: ghcr.io~
 ✘ ⚡ root@openmediavault  ~  

Two observations:

  1. the argument syntax is incorrect
  2. the url has a trailing ~ character

It wouldn’t work like that for anyone. This should work:

docker run --rm curlimages/curl -v https://ghcr.io
1 Like

 ✘ ⚡ root@openmediavault  ~  docker run --rm curlimages/curl -v https://google.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0* Could not resolve host: google.com
* shutting down connection #0
curl: (6) Could not resolve host: google.com
 ✘ ⚡ root@openmediavault  ~ 

that was just the copie/past, here is another example with google.com

 ✘ ⚡ root@openmediavault  ~  docker run --rm curlimages/curl -v http://1.1.1.1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 1.1.1.1:80...
* Connected to 1.1.1.1 (1.1.1.1) port 80
* using HTTP/1.x
> GET / HTTP/1.1
> Host: 1.1.1.1
> User-Agent: curl/8.13.0
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 301 Moved Permanently
< Server: cloudflare
< Date: Sat, 12 Apr 2025 20:59:37 GMT
< Content-Type: text/html
< Content-Length: 167
< Connection: keep-alive
< Location: https://1.1.1.1/
< CF-RAY: 92f5a6073f2f9ec2-CDG
< 
{ [167 bytes data]
100   167  100   167    0     0  17230      0 --:--:-- --:--:-- --:--:-- 18555
* Connection #0 to host 1.1.1.1 left intact
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
 ⚡ root@openmediavault  ~  

 ⚡ root@openmediavault  ~  curl -v https://www.google.com
*   Trying 142.250.75.228:443...
* Connected to www.google.com (142.250.75.228) port 443 (#0)

It indeed looks like something is fishy with the dns resolvers configured in /etc/resolv.conf.

It works for me, but since the -L argument is missing curl will not follow redirects, which is what you see in your 2nd request as well.

I assume your third post is to show that it’s working directly on the host?

You can use the netshoot image to troubleshoot network issues, for instance like this:

# docker run -it --rm nicolaka/netshoot <command>
docker run -it --rm nicolaka/netshoot nslookup google.com

id did a lot of tests, the problem apears only on some images ( the image dosent have right to read its own /etc/resolv.conf file) :

docker run --rm --network host curlimages/curl -v https://google.com

curlimages doesn’t work but alpine do.

docker run --rm alpine/curl -v https://google.com

for information i encountered this problem the first time trying to install nextcloud aio, it cant pull the different images it needed cause it cant resolv there repo urls… (some containers work just fine)

 ✘ ⚡ root@openmediavault  ~  docker run --rm alpine cat /etc/resolv.conf
# Generated by Docker Engine.
# This file can be edited; Docker Engine will not make further changes once it
# has been modified.

nameserver 8.8.8.8
nameserver 1.1.1.1
options single-request

# Based on host file: '/etc/resolv.conf' (legacy)
# Overrides: [nameservers options]
 ⚡ root@openmediavault  ~  docker run --rm curlimages/curl cat /etc/resolv.conf

cat: can't open '/etc/resolv.conf': Permission denied
 ✘ ⚡ root@openmediavault  ~  

Solution
it was indeed a permission problem, inside curlimages i changed chmod 644 /etc/resolv.conf # Makes it readable by all