Background
Say I have a docker-composer setup with a maven
container, and a mysql
container.
I can make the Maven container depends_on: mysql
, but it doesn't wait until it's "ready". It just waits until it's running. But I have some init scripts in the MySQL container that needs to run before it's truly ready.
What I'd like to be able to do is make the Maven container wait by repeatedly trying to establish a connection to the database.
The problem with this is that the Maven container has neither iputils
, nor apt-get
.
Current solution
Maven allows you to hook into the lifecycle stages of the Java application, so you can do programmatic checks from the Java code. This is the current working solution. However, I'd prefer to be able to do this before the application starts, in a more CLI way.
Question
Can containers that aren't alpine
or ubuntu
or whatever, still get commands like ping
and nc
even though they don't have apt-get
?
Alternatively, are there any other clever solutions to get the desired outcome?