You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Issue with ApacheDockerHttpClient Handling unix:// Connections #2380
I wanted to bring to your attention an issue I've encountered with the ApacheDockerHttpClient when connecting to Docker via a Unix socket (unix://). Specifically, when the client detects a unix:// connection, it automatically changes the host to localhost:2375. This behavior causes issues when the Docker host is intended to be a Unix socket, and not TCP.
This seems to be problematic both on Linux and Windows environments, as it tries to connect to the wrong endpoint (localhost), resulting in the following error:
HttpHostConnectException: Connect to unix://localhost:2375 failed: Connection refused
Interestingly, this issue does not occur when using the OkHttpDockerHttpClient. The OkHttp client correctly handles the unix:// scheme without trying to alter the connection to localhost, which resolves the issue.
It would be great if we could review and potentially update the handling of unix:// connections in ApacheDockerHttpClient to prevent this automatic conversion to localhost.
Let me know if you need any further details or assistance on this.
Yes, I can second this. Encountering the same issue.
In addition: I just tried to bypass this bug by switching to Zerodep. Sadly this issue occurs there as well. So i'd suspect the base DockerHttpClient to have this issue.
@muhammetbolat I ended up not using this Library.
Instead I used a Plugin which generates a WebClient from dockers OpeAPI spec. It's Not as clean as using docker-Java but it works.
@latamsystems no it actually isn't, since it's maintenance, stability and security isn't fully ensured on a long term basis.
If you look into the readme for the transports you'll see what I'm talking about. It's not a appropriate basis to build your application on if you're planning it to be in production use later on.
However, they could not have any long term support plan for OkDockerHttpClient. They put question mark on transport.md file. They must be solve or must support this client in future.
`
private static final String DOCKER_HOST = "unix:///var/run/docker.sock";
private final DockerClient dockerClient;
public DockerSocketExecutor() {
var config = DefaultDockerClientConfig.createDefaultConfigBuilder()
.withDockerHost(DOCKER_HOST)
.withDockerTlsVerify(false)
.build();
var httpClient = new OkDockerHttpClient.Builder()
.dockerHost(config.getDockerHost())
.sslConfig(config.getSSLConfig())
.build();
this.dockerClient = DockerClientBuilder.getInstance(config)
.withDockerHttpClient(httpClient)
.build();
}
I experience the issue as well. I could track that issue down to an incompatability in Apache HttpClient between versions 5.2.1 and 5.4.1 . Tracking the issue further brought me to https://issues.apache.org/jira/browse/HTTPCLIENT-2348 where the developer of Apache HttpClient states about docker-java
The maintainer of the library should upgrade to HttpClient 5.4.1 and remove references to deprecated code. We, as a project, do not support unix protocol scheme, so apparently they must have some custom code that extends HttpClient's functionality.
This issue also brought me to #2364 which seems to upgrade docker-java to Apache HttpClient 5.4.2 and fix incompatibiltites. Release and review might be delayed at least until end of March according to @eddumelendez .
Here are some workarounds for the meantime:
Use OkDockerHttpClient as recommended by the previous commentators (didn't test myself)
Downgrade to Apache HttpClient 5.2.1 (works also with newest HttpCore 5.3.3)
Activity
Severon96 commentedon Feb 18, 2025
Yes, I can second this. Encountering the same issue.
In addition: I just tried to bypass this bug by switching to Zerodep. Sadly this issue occurs there as well. So i'd suspect the base DockerHttpClient to have this issue.
muhammetbolat commentedon Feb 25, 2025
I am third one to encountering this issue. Do you have any updates about solving this issue? @latamsystems @Severon96
Severon96 commentedon Feb 25, 2025
@muhammetbolat I ended up not using this Library.
Instead I used a Plugin which generates a WebClient from dockers OpeAPI spec. It's Not as clean as using docker-Java but it works.
latamsystems commentedon Feb 25, 2025
For everyone, the best alternative is OkDockerHttpClient
Severon96 commentedon Feb 25, 2025
@latamsystems no it actually isn't, since it's maintenance, stability and security isn't fully ensured on a long term basis.
If you look into the readme for the transports you'll see what I'm talking about. It's not a appropriate basis to build your application on if you're planning it to be in production use later on.
muhammetbolat commentedon Feb 26, 2025
Using OkDockerHttpClient solved my problem. Thank you @Severon96 @latamsystems
However, they could not have any long term support plan for OkDockerHttpClient. They put question mark on transport.md file. They must be solve or must support this client in future.
`
`
StefanPenndorf commentedon Feb 27, 2025
Hi all,
I experience the issue as well. I could track that issue down to an incompatability in Apache HttpClient between versions 5.2.1 and 5.4.1 . Tracking the issue further brought me to https://issues.apache.org/jira/browse/HTTPCLIENT-2348 where the developer of Apache HttpClient states about docker-java
This issue also brought me to #2364 which seems to upgrade docker-java to Apache HttpClient 5.4.2 and fix incompatibiltites. Release and review might be delayed at least until end of March according to @eddumelendez .
Here are some workarounds for the meantime:
StefanPenndorf commentedon Feb 27, 2025
This issue duplicates #2363
eddumelendez commentedon Apr 1, 2025
Closing as duplicate
docker-java-transport-httpclient5broken over Unix sockets (regression inhttpclient55.4) #2363