skip to Main Content

I have been setting up a Jenkins pipeline using docker images. Now I need to run various services like MySQL, Redis, Memcache, Beanstalkd and Elasticsearch. To wait the job until MySQL is ready, I am using the following command :

sh "while ! mysqladmin ping -u root -h mysqlhost ; do sleep 1; done"
sh 'echo MySQL server is up and running'

Where mysqlhost is the hostname I have provided for the container. Similarly, I need to check and wait for Redis, Memcached, Beanstalkd and Elasticsearch. But pinging to these services are not working as it is done for MySQL . How can I implement this ?

2

Answers


  1. You can do a curl to this services in order to check if they are alive or not.
    For redis you can also do https://redis.io/commands/ping

    Login or Signup to reply.
  2. The Docker docs mention this script to manage container readiness checks: https://github.com/vishnubob/wait-for-it

    I also use this one which is compatible with Alpine:
    https://github.com/eficode/wait-for

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search