1

I'm creating a mariaDB container via docker run with -v pathToSQL:/docker-entrypoint-initdb.d/script.sql option via Java. I have no idea how to find out when the container is ready to be connected with my JDBC client. How can I find out when the initial script stopped executing and the DB is ready to work? I'd like to avoid something like Thread.sleep(20000), which is my current solution. I'd like to achieve something like this:

Execute command
IF
    return OK then connect do DB
ELSE
    wait 5 second and execute command again.
moebius
  • 2,061
  • 11
  • 20
ogarogar
  • 323
  • 2
  • 14
  • Can you tell us which image you're using or an output of the Dockerfile, as well as the full docker run command? – moebius Jul 24 '18 at 12:58
  • @rahoogan I'm using the latest mariadb image and whole run command looks like this: "docker run mariadb -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=dbname -v C:/script.sql:docker-entrypoint-initdv.d/scirpt.sql -p 3310:3306" – ogarogar Jul 24 '18 at 13:02
  • When I run this command on my machine: `docker run -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=dbname -p 3310:3306 -v C:/script.sql:/docker-entrypoint-initdb.d/script.sql mariadb`, it seems to work for me - the logs get printed to console, and I can see: `2018-07-24 13:23:23 0 [Note] mysqld: ready for connections`. You can also inspect logs at anytime with `docker logs ` – moebius Jul 24 '18 at 13:26
  • But I'm usign https://github.com/docker-java/docker-java , so I don't see logs when I start my container. – ogarogar Jul 24 '18 at 14:26

0 Answers0