-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Always obtain DOCKER_HOST from env (#1770) #1771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bsideup
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? ( testcontainers-java/core/src/main/java/org/testcontainers/utility/ResourceReaper.java Line 75 in 50ff2c5
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch!
| @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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <bsideup@gmail.com>
|
We'll tackle this in #2985 instead, as the changes there make the majority of this PR moot. |
It is based on #1770