Pipeline has to wait for application inside a docker container

I have a CI pipeline, that is building a docker image. After building is complete the image runs.
When the container starts, it needs some time, till the container is ready to use, because the container has to load some code and start a web application.
And here is my problem. The pipeline thinks that the container is started successful und will proceed with the next “test” stage. But right now there is nothing to test.
How can the pipeline wait for the application inside the builded container?

I always create a little shell wrapper for this.

1 Like

Good idea, do you have a little example for me? I have no idea, how to check. Maybe with curl. But how can I tell the pipeline, that the wrapper was successful? Thank you very much!

I found a solution, thank you for your idea!

You are welcome, for other readers, we put a comment with the pipeline ID in the start page, afterwards this script will poll for 5 minutes until this appears:

   - |-
      for i in `seq 60`
        if curl -s http://$HOST_UNDER_TEST/ | grep pipelines/$CI_PIPELINE_ID
          echo pipelines/$CI_PIPELINE_ID not found, sleeping
          sleep 5
      curl -s http://$HOST_UNDER_TEST/ | grep pipelines/$CI_PIPELINE_ID