{"action":"created","issue":{"url":"https://api.github.com/repos/rhuss/docker-maven-plugin/issues/328","labels_url":"https://api.github.com/repos/rhuss/docker-maven-plugin/issues/328/labels{/name}","comments_url":"https://api.github.com/repos/rhuss/docker-maven-plugin/issues/328/comments","events_url":"https://api.github.com/repos/rhuss/docker-maven-plugin/issues/328/events","html_url":"https://github.com/rhuss/docker-maven-plugin/issues/328","id":116900014,"number":328,"title":"starting mysql - can't wait correct time...","user":{"login":"anztenney","id":7491718,"avatar_url":"https://avatars.githubusercontent.com/u/7491718?v=3","gravatar_id":"","url":"https://api.github.com/users/anztenney","html_url":"https://github.com/anztenney","followers_url":"https://api.github.com/users/anztenney/followers","following_url":"https://api.github.com/users/anztenney/following{/other_user}","gists_url":"https://api.github.com/users/anztenney/gists{/gist_id}","starred_url":"https://api.github.com/users/anztenney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anztenney/subscriptions","organizations_url":"https://api.github.com/users/anztenney/orgs","repos_url":"https://api.github.com/users/anztenney/repos","events_url":"https://api.github.com/users/anztenney/events{/privacy}","received_events_url":"https://api.github.com/users/anztenney/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-14T05:45:27Z","updated_at":"2015-11-14T15:35:18Z","closed_at":null,"body":"I'm trying to start a mysql docker before the integration test phase.  Here is the excerpt from my pom.xml:\r\n```xml\r\n<plugins>\r\n\t\t\t<plugin>\r\n\t\t\t\t<groupId>org.jolokia</groupId>\r\n\t\t\t\t<artifactId>docker-maven-plugin</artifactId>\r\n\t\t\t\t<version>0.13.6</version>\r\n\t\t\t\t<configuration>\r\n\t\t\t\t\t<images>\r\n\t\t\t\t\t\t<image>\r\n\t\t\t\t\t\t\t<alias>database</alias>\r\n\t\t\t\t\t\t\t<name>mysql:5.7</name>\r\n\t\t\t\t\t\t\t<run>\r\n\t\t\t\t\t\t\t\t<wait>\r\n\t\t\t\t\t\t\t\t\t<log>mysqld: ready for connections</log>\r\n\t\t\t\t\t\t\t\t\t<time>20000</time>\r\n\t\t\t\t\t\t\t\t</wait>\r\n\t\t\t\t\t\t\t\t<env>\r\n\t\t\t\t\t\t\t\t\t<MYSQL_ROOT_PASSWORD>abc123</MYSQL_ROOT_PASSWORD>\r\n\t\t\t\t\t\t\t\t\t<MYSQL_DATABASE>testdb</MYSQL_DATABASE>\r\n\t\t\t\t\t\t\t\t\t<MYSQL_USER>mysql</MYSQL_USER>\r\n\t\t\t\t\t\t\t\t\t<MYSQL_PASSWORD>mysql</MYSQL_PASSWORD>\r\n\t\t\t\t\t\t\t\t</env>\r\n\t\t\t\t\t\t\t\t<ports>\r\n\t\t\t\t\t\t\t\t\t<port>3306:3306</port>\r\n\t\t\t\t\t\t\t\t</ports>\r\n\t\t\t\t\t\t\t</run>\r\n\t\t\t\t\t\t</image>\r\n\t\t\t\t\t</images>\r\n\t\t\t\t</configuration>\r\n\t\t\t\t<executions>\r\n\t\t\t\t\t<execution>\r\n\t\t\t\t\t\t<id>docker:start</id>\r\n\t\t\t\t\t\t<phase>pre-integration-test</phase>\r\n\t\t\t\t\t\t<goals>\r\n\t\t\t\t\t\t\t<goal>start</goal>\r\n\t\t\t\t\t\t</goals>\r\n\t\t\t\t\t</execution>\r\n\t\t\t\t\t<execution>\r\n\t\t\t\t\t\t<id>docker:stop</id>\r\n\t\t\t\t\t\t<phase>post-integration-test</phase>\r\n\t\t\t\t\t\t<goals>\r\n\t\t\t\t\t\t\t<goal>stop</goal>\r\n\t\t\t\t\t\t</goals>\r\n\t\t\t\t\t</execution>\r\n\t\t\t\t</executions>\r\n\t\t\t</plugin>\r\n\t\t\t<plugin>\r\n\t\t\t\t<artifactId>maven-failsafe-plugin</artifactId>\r\n\t\t\t\t<version>2.17</version>\r\n\t\t\t\t<executions>\r\n\t\t\t\t\t<execution>\r\n\t\t\t\t\t\t<id>integration-test</id>\r\n\t\t\t\t\t\t<goals>\r\n\t\t\t\t\t\t\t<goal>integration-test</goal>\r\n\t\t\t\t\t\t</goals>\r\n\t\t\t\t\t</execution>\r\n\t\t\t\t\t<execution>\r\n\t\t\t\t\t\t<id>verify</id>\r\n\t\t\t\t\t\t<goals>\r\n\t\t\t\t\t\t\t<goal>verify</goal>\r\n\t\t\t\t\t\t</goals>\r\n\t\t\t\t\t</execution>\r\n\t\t\t\t</executions>\r\n\t\t\t\t<configuration>\r\n\t\t\t\t\t<systemPropertyVariables>\r\n\t\t\t\t\t\t<mysql.jdbc.url>jdbc:mysql://${docker.host.address}/testdb</mysql.jdbc.url>\r\n\t\t\t\t\t</systemPropertyVariables>\r\n\t\t\t\t</configuration>\r\n\t\t\t</plugin>\r\n\t\t</plugins>\r\n```\r\n\r\nThe docker container starts, and my test runs, but it gets a **Caused by: java.net.ConnectException: Connection refused: connect**\r\n```java\r\nconn = DriverManager.getConnection(mysqlUrl, user, password);\r\nstmt = conn.createStatement();\r\nstmt.execute(IOUtils.toString(getClass().getClassLoader().getResource(\"mysqlScript.sql\")));\r\n```\r\n\r\nHowever, if I add a `Thread.sleep(5000)` before I call getConnection, it is able to connect without a problem.  I assume this is some issue with the docker port/container not being immediately available.  Is there any combination in the `<wait>` section to wait an extra 5 seconds, or some other way to make sure this works?"},"comment":{"url":"https://api.github.com/repos/rhuss/docker-maven-plugin/issues/comments/156712580","html_url":"https://github.com/rhuss/docker-maven-plugin/issues/328#issuecomment-156712580","issue_url":"https://api.github.com/repos/rhuss/docker-maven-plugin/issues/328","id":156712580,"user":{"login":"jgangemi","id":1831839,"avatar_url":"https://avatars.githubusercontent.com/u/1831839?v=3","gravatar_id":"","url":"https://api.github.com/users/jgangemi","html_url":"https://github.com/jgangemi","followers_url":"https://api.github.com/users/jgangemi/followers","following_url":"https://api.github.com/users/jgangemi/following{/other_user}","gists_url":"https://api.github.com/users/jgangemi/gists{/gist_id}","starred_url":"https://api.github.com/users/jgangemi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgangemi/subscriptions","organizations_url":"https://api.github.com/users/jgangemi/orgs","repos_url":"https://api.github.com/users/jgangemi/repos","events_url":"https://api.github.com/users/jgangemi/events{/privacy}","received_events_url":"https://api.github.com/users/jgangemi/received_events","type":"User","site_admin":false},"created_at":"2015-11-14T15:35:18Z","updated_at":"2015-11-14T15:35:18Z","body":"i do something very similar for my postgres database, although i only wait on a `log` and i have no issues. are you sure mysql is actually up accepting connections by the time `getConnection()` is called?\r\n\r\nyou could specify a `time` condition on it's own and the plugin would block for that specified time, but i realize that might not be idea. we'd need to add an enhancement to allow blocking for a specified additional interval since `time` cannot be used for this."}}