Reputation: 193
I am running a Virtuoso docker and than loading data on it.
I have all this in a bash script. Since this command run sequentially loading the data usually fails since Virtuoso didn't fully start yet.
The easy solution is just to add a delay (sleep), and it works. It's a bit dirty solution though.
I found this command
docker inspect -f {{.State.Running}} $CONTAINER_ID
But this only tells if the container is running or not.
Is there a way to check if the daemon on docker fully started (in this case Virtuoso) before loading the data?
Upvotes: 1
Views: 320
Reputation: 263469
The generic process is to define a healthcheck for your application and then check that health state:
docker inspect --format '{{.State.Health.Status}}' $container_id
The desired output is healthy
.
For more details on how to define a healthcheck for your image, see https://docs.docker.com/engine/reference/builder/#healthcheck
The actual command you define for a healthcheck will vary per application being run inside the container.
Upvotes: 1
Reputation: 10064
You could check if the TCP port is open with wait-for-it script:
container_ip = $(docker inspect --format "{{range .NetworkSettings.Networks}}{{ .IPAddress }}{{end}}") $CONTAINER_ID
until $(./wait-for-it.sh $container_ip:<virtuoso_port> --timeout=1)
do
echo "Virtuoso is not responding";
done;
Upvotes: 1