Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl is not working inside a docker container

Im using an nginx container on my VMs as a proxy to some services.

In most of the VMs it works just fine, but I have a single VM which the nginx does not work in it. Tried to make requests with curl inside the container and it does not work, whereas, the curls do work outside the container on the VM.

Because it works on all the other VMs, I assumed it is a problem with the docker configuration on that specific VM.

The error i get from the curl inside the container is: Failed to connect to x.x.x.x port 443: no route to host

(Tried maybe to add the --add-host parameter in the docker run, but it didn't help either)

Appreciate any help :)

like image 242
user3927415 Avatar asked Feb 26 '26 10:02

user3927415


1 Answers

Solved my problem by appending --net=host to the docker run command.

Apparently, for this specific VM, I had to explicitly define the network of the nginx container as host

(which enable the container to sends request to the outside world)

like image 182
user3927415 Avatar answered Feb 28 '26 03:02

user3927415



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!