Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Pipelines - Move to next step after successfully running a container.

obsydian March 23, 2023


I am building a pipeline to build and distribute a dockerised application. I am able to get the container built and running but because it's essentially an open-ended container that runs and runs I need to ensure it is running and then stop the container and move to the next steps in the pipeline.

Is there any way to do this? The reason I want to ensure that it runs is I have experienced issues in the past where dependencies in parts of the Dockerfile stages were updated and caused the container to build but not run.

Currently, I have tried curl'ing the localhost but that doesn't get triggered. the container runs and as it's long-standing it therefore just stays on that command indefinitely.

1 answer

0 votes
Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 23, 2023

Hey @obsydian 

It's possible and mainly depends on your definition of "successful run" of your image. Does "successful" mean that the container run for X seconds? or reached a certain point in the code? something else?  

Basically, you would need to:

  1. Run your container in the background, using "-d" flag.
  2. Run "sleep" in your step to let your container reach the desired point.
  3. Check if the container reached the desired point. Depending on your need, it might be checking if the container is still running, checking the container's logs, etc'.
  4. Exit the step with a suitable exit code

Hope that helps   

obsydian March 23, 2023

By runs I just need to check it doesn't error on running. I just need to check that the server is up and running and that could be done by checking the container log which shows the following.

[info] The server listening at port: 4000

 Or by pinging the healthcheck endpoint. I'm not sure which is preferable or how I go about doing this as the next step in the pipeline. Any comments or leads welcome but thanks for your input already.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events