docker-client icon indicating copy to clipboard operation
docker-client copied to clipboard

What is the reason of existance of UnixConnectionSocketFactory.sanitizeUri ??

Open leandrodvd opened this issue 8 years ago • 3 comments

Description

Hi, can someone please explain what is happening in this method

public static URI sanitizeUri(final URI uri) {
    if (uri.getScheme().equals("unix")) {
      return URI.create("unix://localhost:80");
    } else {
      return uri;
    }
  }

Inside the class UnixConnectionSocketFactory ? https://github.com/spotify/docker-client/blob/master/src/main/java/com/spotify/docker/client/UnixConnectionSocketFactory.java

This will transform any value of DOCKER_HOST that starts with unix:// to "unix://localhost:80" and I don't understand the reason for that.

leandrodvd avatar Mar 24 '18 00:03 leandrodvd

@ctrafa ^ FYI

leandrodvd avatar Mar 26 '18 15:03 leandrodvd

@leandrodvd that is a good question - I don't really remember the history of that myself. But one thing to note is that this only really changes the value of the DOCKER_HOST as stored in memory in this library - and since UnixConnectionSocketFactory is creating a connection with a unix socket, the localhost part should be irrelevant.

It may have been that the library used for unixsockets at the time (see e5efce9 for when this code was added) required addresses of a certain format, but I'm not sure.

mattnworb avatar Apr 03 '18 16:04 mattnworb

Thanks for the clarification @mattnworb I had a suspect that this could be causing me issues but since the localhost part should be irrelevant, this is not the case (actually my issue was just a conflict of dependency versions, not directly related to this).

I'll close this issue for now, but I have an emotional feeling that this sanitizeUri method can cause problems in some uncommon scenario like someone for some reason using an uncommon value like unix://something-uncommon in DOCKER_HOST (but honestly I can't imagine a real scenario for that)

ok, too hypothetical - closing this

leandrodvd avatar Apr 05 '18 12:04 leandrodvd