-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Latest Docker for Mac - apparent change to port forwarding breaks TCP liveness checks #160
Comments
Scratch that idea as a potential fix - as I suspected, it only works where the container process has something to send and doesn't wait for data from the client first. |
Brief update: doing the equivalent of |
Should be fixed in a later DfM beta, as per this post: https://forums.docker.com/t/port-forwarding-of-exposed-ports-behaves-unexpectedly/15807/2 |
Current recommended workaround for this issue is to implement a custom service-specific |
@rnorth got bitten by this issue. Looks like it's not fixed in the latest release of DfM. Do you have any ideas what to do with it? Update: I managed to workaround it by using: setWaitStrategy(new AbstractWaitStrategy() {
@Override
protected void waitUntilReady() {
Unreliables.retryUntilTrue(1, TimeUnit.MINUTES, () -> {
ExecResult result = container.execInContainer("/bin/bash", "-c", "</dev/tcp/localhost/" + getExposedPorts().get(0) + " && echo success");
return result.getStdout().contains("success");
});
}
}); It uses BASH's magical device |
Ah, interesting @bsideup. The workaround (that IIRC @outofcoffee has used) is a service-specific wait strategy. e.g. to change the test from 'is the socket listening?' to 'does the socket talk HTTP?' It's frustrating. Your workaround is very clever; I'd tried something similar but not as elegant 😆 I think bringing this into TC and making it the default might be a hack too far, but perhaps there's some merit in making it available so people can opt-in..? I like the principle of us doing the hard/dirty work so that users don't have to 😄 |
@rnorth doing it right now (bash-based port check in Docker for Mac environment), will send PR soon |
This long-standing part of our container liveness checks seems to be broken on Docker for Mac from at least beta 14 onwards:
The original behaviour of this was to simply verify that the relevant TCP port was listening, catching an IOException if the container was not listening yet. However, now Docker for Mac seems to be running its own perpetually listening TCP proxy that accepts the connection regardless of whether there is actually a listening process inside the container.
e.g. outside of testcontainers, this demonstrates the behaviour:
This seems to make the current wait check too dumb!
I'd be keen to know if others are experiencing this.
I suspect the fix should include opening an inputstream and verifying that the first read doesn't indicate end-of-stream, but I'd like to do some checking to be sure that this doesn't have unintended consequences.
The text was updated successfully, but these errors were encountered: