If you are testing with just localhost, then it bypasses your choice of unix:///var/run/docker.sock. You need to test with that host rather than localhost.
tcp://172.xxx.xxx.xxx:2375 (the IP serveur where my container runs)
and I obtain
org.apache.hc.client5.http.HttpHostConnectException: Connect to http://172.xxx.xxx.xxx:2375 [/172.xxx.xxx.xxx] failed: Connection refused
I read that :
If you are running jenkins as container, in the docker host uri field you have to enter unix or tcp address of the docker host. But since you are running jenkins as container, the container can’t reach docker host unix port.
So, we have to run another container that can mediate between docker host and jenkins container. It will public docker host’s unix port as its tcp port. Follow the instructions to create socat container Docker
After creating the socat container, you can go back the docker configuration in jenkins and enter tcp://socat-container-ip:2375
you don’t get to make up host names… unix://localhost:2375 is not a valid host name
tcp://localhost:2375 is valid for connecting to port 2375 over TCP. You have to configure dockerd to listen on this port first. unix://var/run/docker.sock is valid for connecting using a socket file directly on your local machine. This is always configured.