-
Notifications
You must be signed in to change notification settings - Fork 122
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 for 0.0.0.0:8080 instead of localhost:8080 #51
Comments
Hi @bifunctor ! First of all, I'm trying to run your code but it looks like Are you sure that you need |
Hi LMnet First of all, thanks for your response. I will publish the sweetsoft/sapmock container at this evening, because I am using
How to get the random port? Thanks |
Here is the You should add port you want to expose from the container in the override val container = GenericContainer("nginx:latest",
exposedPorts = Seq(80)
)
"some test" in {
container.mappedPort(80) // will return random mapped port
} |
Hi @LMnet I've changed as you told me as the following:
But I've still got the message:
The statement
What am I doing wrong? Hint: With the Thanks |
I didn't see from the I suggest you to try to run your application from the command line first, and after that integrate it with testcontainers. |
Hi @LMnet I've tried to run the server application from the commnad line and it works.
and I could reached the web application via the browser. But with I am using https://github.com/sbt/sbt-native-packager to publish the docker image on local and as
As mentioned above, starting the application manually with docker command, I have the access to the application. The best way to figure out, what I mean is, to download the source code from the application on https://gitlab.com/sweetsoft/sapmock and Hint: With the Thanks for your help. |
That is the whole log:
Look at the end, it starts the container. But it should start before this message appears
Thanks |
I tried to use your container from the command line:
Here is
It looks like docker successfully bound 32878 host port to the 8080 container port. In another terminal I tried to use
But as you can see from the output, it returns 404. That's why Testcontainers can't start your container. I didn't deeply dive in your application code, but I think that issue is on the application side. Try to use steps above to reproduce the problem and solve it. |
You are right. I corrected the error and pushed the new changes to the docker hub https://cloud.docker.com/u/kostonstyle/repository/docker/kostonstyle/sapmock. I run the container after the change as the following:
And on the other window, I did:
As you can see, I've got now the response code 200.
I do not know anymore, what should I do. Thanks |
I think I found the problem. After starting your application is waiting for the user input. When user press enter — application stops. But it will work only with the interactive console mode. Try to run your app in docker from the command line without To fix the problem your application should be able to work in the daemon mode. |
Wow....Thanks so much for your help. It works!!!!!! 1000 thanks. |
@LMnet great job! thank you for helping 👍 |
Hi all
Wait for 0.0.0.0:8080 instead of localhost:8080
In
GenericContainer
class, it exists a methodwaitingFor
, that waits for status code200
as reponse from the server.I am running a web application in a container and use
0.0.0.0
as host instead oflocalhost
.When I try to run the
sbt test
, I've got following timeout:I am using the test container as the following:
When I would remove
waitStrategy = Wait.forHttp("/")
, then it works fine but withwaitStrategy = Wait.forHttp("/")
it goes into the timeout.
How to tell the
Testcontainer
to listen on0.0.0.0
instead of thelocalhost
?I have described the problem with the localhost here: https://stackoverflow.com/questions/56201718/why-does-the-client-can-not-connect-to-localhost8080/56201938?noredirect=1#comment99027626_56201938
Thanks
The text was updated successfully, but these errors were encountered: