Issue:
Just updated my Ubuntu 20.04 server, curl inside docker container stopped working.
Tried uninstalling and reinstalling docker according to the official guide. Docker version is
Docker version 20.10.21, build baeda1f
Tried running alpine with command line
sudo docker run --rm -it alpine
/ # apk add curl
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz
(1/5) Installing ca-certificates (20220614-r0)
(2/5) Installing brotli-libs (1.0.9-r6)
(3/5) Installing nghttp2-libs (1.47.0-r0)
(4/5) Installing libcurl (7.83.1-r4)
(5/5) Installing curl (7.83.1-r4)
Executing busybox-1.35.0-r17.trigger
Executing ca-certificates-20220614-r0.trigger
OK: 8 MiB in 19 packages
So far so good, but running curl gives this error
/ # curl -v example.com
* getaddrinfo() thread failed to start
* Could not resolve host: example.com
* Closing connection 0
curl: (6) getaddrinfo() thread failed to start
Things that I have tried:
-
curl works on the host machine
-
nslookup works
/ # nslookup example.com
Server: 192.168.18.1
Address: 192.168.18.1:53
Non-authoritative answer:
Name: example.com
Address: 93.184.216.34
Non-authoritative answer:
Name: example.com
Address: 2606:2800:220:1:248:1893:25c8:1946
- curl IP works
/ # curl 93.184.216.34
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>404 - Not Found</title>
</head>
<body>
<h1>404 - Not Found</h1>
</body>
</html>
- Running with a security option (I have read that this might be the cause of the problem on older docker version). Gives out the same error
sudo docker run --security-opt seccomp=unconfined --rm -it alpine
- Curl works fine on ubuntu 16.04, 18.04 images.
- But not on ubuntu 20.04, fedora (latest) images. Same error message is given.
I have exhausted myself looking for solution. I think this is either DNS or C library problem. I was wondering if you guys can help me out with this.
Thanks