Gambi
Gambi

Reputation: 554

My Docker containers can ping but can't curl URL

I'm using Docker version 20.10.21 under Ubuntu server 22.04. Since a week ago, my Docker containers can't reach public APIs on the internet (for example Public holidays in France). They could reach it before an apt update and upgrade was done.

I was thinking that it was a Docker bridge network related issue in a first place, so I tried this solution: My docker container has no internet

Then, I tried

docker network prune

, then I tried to uninstall and reinstall Docker.

After investigations, I was wrong about my diagnosis because I can ping public names, but I can't curl any URL:

ping but not curl

I don't understand why this issue suddenly happened and I'm out of thoughts to solve this.

UPDATE:

Docker containers can't curl any URL, but my Ubuntu host does.

With docker host network, curl is working for the given API.

On the other hand, if I'm running the same container on Docker Desktop, on my dev computer, that works well.

Upvotes: 4

Views: 6196

Answers (1)

Gambi
Gambi

Reputation: 554

I finally found out what was the issue. The MTU of my host network interface was different from the default value of the docker network (1500).

I checked my network interface MTU:

ip a | grep mtu

eno1 mtu value

And then, I settled the MTU for the docker daemon in /etc/docker/daemon.json :

{
    "mtu" : 1280
}

Then don't forget to restart docker:

systemctl restart docker

Upvotes: 2

Related Questions