-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
Wait.UntilPortsAreAvailable throws exception if the container doesn't have bash #178
Comments
@jdelucaa thanks for your effort, you're right. Of course, we're supposed to follow the standard, especially if we don't need any I think it's a good idea to switch to We should probably rename If you need any help, let me know. |
PR #179 |
…ilPortsAreAvailable' {Added multiple commands to verify port availability}
…ilBashCommandsAreCompleted.Until' {Changed to use /bin/sh instead of /bin/bash to execute the commands}
…ashCommandsAreCompleted' {Renamed to WaitUntilShellCommandsAreCompleted}
@jdelucaa I'll check #180 and #181 and probably release a new minor version after that. Until then you could use |
Describe the bug
When building a container with
Wait.UntilPortsAreAvailable
, I get an expection when starting the container:Docker.DotNet.DockerApiException: 'Docker API responded with status code=BadRequest, response={"message":"OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown"}
This is because my container doesn't have
bash
installed, onlysh
or other implementation of shell..To Reproduce
Steps to reproduce the behavior:
Expected behavior
The commands used to verify the availability of the ports should support other shells.
Screenshots
Not necessary
Desktop (please complete the following information):
Additional context
I did the following changes to the code that solved the problem
In
WaitUntilBashCommandsAreCompleted.cs
changed from/bin/bash
tobin/sh
- becausesh
will point to the actual implementation of the shell ( bash, dash, etc.. ), I think it'll work for most cases.The expcetion was gone with that change, but the thread got stucked somewhere, I figured there was something wrong with the command used in
WaitUntilPortsAreAvailable.cs
, for some reason that command doesn't work in my container, it says the directory does not exist, so I changed the line 8 fromtimeout 15 bash -c \"echo > /dev/tcp/localhost/8080\"
to a boolean expression with some ways to try and check if the port is available (like the testcontainers-java version does):true && (cat /proc/net/tcp{{,6}} | awk '{{print $2}}' | grep -i :{port} || nc -vz -w 1 localhost {port} || /bin/bash -c '</dev/tcp/localhost/{port}')
;Those changes saved my day... let me know if you think it's a good solution to open a PR to fix the issue.
The text was updated successfully, but these errors were encountered: