Skip to content
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 until container started - doesn't end and in the meantime creates multiple containers (MySQLContainer) #511

Closed
ori-n opened this issue Dec 5, 2017 · 18 comments
Labels

Comments

@ori-n
Copy link

ori-n commented Dec 5, 2017

I tried this simple code:
try (MySQLContainer mySQLContainer = new MySQLContainer()) { mySQLContainer.start(); mySQLContainer.stop(); }
In the log I get:
[INFO] 2017-12-05 16:50:48,709 [main] 🐳 [mysql:latest] waitUntilContainerStarted - Waiting for database connection to become available at jdbc:mysql://localhost:32770/test using query 'SELECT 1'

And in the meantime containers are created every 2 min:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
7504e73de3d5 mysql:latest "docker-entrypoint..." 11 minutes ago Up 11 minutes 0.0.0.0:32770->3306/tcp
1ae62c3a699c mysql:latest "docker-entrypoint..." 13 minutes ago Up 13 minutes 0.0.0.0:32769->3306/tcp

Am I doing something wrong. Tries both on docker on windows and docker on ubuntu and got the same results

@kiview
Copy link
Member

kiview commented Dec 5, 2017

Hi @ori-n, can you please share a more complete example of your code?
Are you using testcontainers in a JUnit context or somewhere else?

@ori-n
Copy link
Author

ori-n commented Dec 6, 2017

Below is the complete function - I'm using junit

    @Test
    public void runMySql() throws Exception {
        try (MySQLContainer mySQLContainer = new MySQLContainer()) {
            mySQLContainer.start();
            // connect to the db here
            mySQLContainer.stop();
        }
    }

@kiview
Copy link
Member

kiview commented Dec 7, 2017

Can't reproduce this behavior on Docker for Windows. Are both containers removed once the tests have finished?

@ori-n
Copy link
Author

ori-n commented Dec 8, 2017 via email

@kiview
Copy link
Member

kiview commented Dec 8, 2017

I tried your exakt code on the current master branch of testcontainers and it works as expected.

How is it possible for your MySQLContainer to be alpine based? If you don't specify any constructor paramters, the container will use mysql:latest, which is Debian based (see https://hub.docker.com/_/mysql/).

Did you override your local mysql:latest manually on your system?

@ori-n
Copy link
Author

ori-n commented Dec 8, 2017 via email

@kiview
Copy link
Member

kiview commented Dec 9, 2017

Can you maybe upload a complete example project on Github?
Also, what's your Docker version?

@tv-plot
Copy link

tv-plot commented Mar 14, 2018

@kiview
Please take a look at https://github.com/pol12va/testcontainers-demo. I'm having exactly the same issue with MySQL container. Tried with different mysql docker images and different testcontainers versions.
Docker version: Version 17.12.0-ce-mac55 (23011)

@kiview
Copy link
Member

kiview commented Mar 15, 2018

@pol12va
Thanks for your example, I can reproduce the described behavior. I will look into this.

@kiview kiview changed the title wait until container started - doesn't end and in the meantime creates multiple containers wait until container started - doesn't end and in the meantime creates multiple containers (MySQLContainer) Mar 15, 2018
@jvujcic
Copy link

jvujcic commented Jul 31, 2018

@kiview
Is there any progress on this. I'm also stuck at
Waiting for database connection to become available at jdbc:mysql://localhost:32770/test using query 'SELECT 1'

@johnedmonds
Copy link

I fixed this by adding the mysql connector dependency to my test.

@EvgeniGordeev
Copy link

Adding mysql connector made it work for mysql:5.7.24, but not for mysql:8.0.13.

@guss77
Copy link
Contributor

guss77 commented Jan 20, 2019

The problem with MySQL 8 could be because of the different authentication scheme introduced in MySQL 8. This is likely the same problem as issue #736.

@stale
Copy link

stale bot commented Apr 20, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

@stale stale bot added the stale label Apr 20, 2019
@rnorth
Copy link
Member

rnorth commented Apr 28, 2019

The spawning of multiple containers may be fixed by #1433

@stale stale bot removed the stale label Apr 28, 2019
@rui-ferreira
Copy link

If you manually connect to the container's DB, while it's "waiting for database connection to become available", the loop resumes. This is just a hint on what may be wrong, not a workaround.

@stale
Copy link

stale bot commented Oct 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

@stale stale bot added the stale label Oct 1, 2019
@rnorth
Copy link
Member

rnorth commented Oct 1, 2019

I’m going to close. As mentioned previously #1433 should have resolved this. If the issue still occurs then of course please reopen.

Sent with GitHawk

@stale stale bot removed the stale label Oct 1, 2019
@rnorth rnorth closed this as completed Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants