Always obtain DOCKER_HOST from env (#1770)#1771
Always obtain DOCKER_HOST from env (#1770)#1771usmanovbf wants to merge 27 commits intotestcontainers:masterfrom
Conversation
bsideup
left a comment
There was a problem hiding this comment.
There is EnvironmentAndSystemPropertyClientProviderStrategy that should use the environment variables, doesn't it work for you?
|
@bsideup Unfortunately not. Because first valid strategy choosed as the |
|
OK, I've finally had time to look into why the So, if Given that we have better code in However, I'd like to make a couple of tweaks to this PR to improve the other strategies along similar lines. I'll do that myself and push shortly. |
|
/AzurePipelines run Windows 10 - Docker for Windows |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@bsideup we discussed this very briefly in person last week, and I think you spotted a flaw. Do you remember what it was? 😬 |
|
@rnorth yes. Strategies (like the npipe one) must filter the value of the env variable to prevent wrong selection (e.g. npipe strategy talking over TCP) |
… a different scheme
…iners-java into 1770_docker_host_env
|
Is there also a way to apply the hosts DOCKER_HOST to Ryuk, if its a unix socket? ( That would resolve issues with deployents that have the docker.sock in an unusual place. |
|
/AzurePipelines run Windows 10 - Docker for Windows |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Just for sanity's sake, I've tested this in our CI environment which is DinD with Given that this is tested on a variety of CI and local environments, I think I'm happy that this doesn't introduce any regressions. WDYT @bsideup, @kiview? |
bsideup
left a comment
There was a problem hiding this comment.
current master's state removes the "TCP or Linux" condition on EnvironmentAndSystemPropertyClientProviderStrategy and now it should take precedence over UnixSocketClientProviderStrategy, which means that we don't need to read DOCKER_HOST there :D So I'd revert it.
But the getDockerUnixSocketPath() change is still helpful.
…entAndSystemPropertyClientProviderStrategy is applied on non-linux systems
|
|
||
| protected static final String DOCKER_SOCK_PATH = "//./pipe/docker_engine"; | ||
| private static final String SOCKET_LOCATION = "npipe://" + DOCKER_SOCK_PATH; | ||
| private static final String SOCKET_LOCATION = System.getenv().getOrDefault("DOCKER_HOST", "npipe://" + DOCKER_SOCK_PATH); |
There was a problem hiding this comment.
I think this change is unnecessary now
| protected static final String SOCKET_LOCATION = "unix:///var/run/docker.sock"; | ||
| protected static final String DOCKER_SOCK_PATH = "/var/run/docker.sock"; |
There was a problem hiding this comment.
nit (reducing the changeset):
| protected static final String SOCKET_LOCATION = "unix:///var/run/docker.sock"; | |
| protected static final String DOCKER_SOCK_PATH = "/var/run/docker.sock"; | |
| protected static final String DOCKER_SOCK_PATH = "/var/run/docker.sock"; | |
| private static final String SOCKET_LOCATION = "unix://" + DOCKER_SOCK_PATH; |
| @Override | ||
| protected boolean isApplicable() { | ||
| return SystemUtils.IS_OS_LINUX; | ||
| return SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC_OSX; |
| @Override | ||
| protected boolean isApplicable() { | ||
| return SystemUtils.IS_OS_LINUX; | ||
| return SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC_OSX; |
There was a problem hiding this comment.
Brave new world:
| return SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC_OSX; | |
| return SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC; |
Co-authored-by: Sergei Egorov <[email protected]>
|
We'll tackle this in #2985 instead, as the changes there make the majority of this PR moot. |
It is based on #1770