> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/dependency-mgmt-strategies.md).

# Dependency management strategies

Learn how you can manage dependencies in Harness CI pipelines.

Use [Background steps](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/background-step-settings.md) to maintain long-running services over the duration of a stage.

## What you will learn from this topic

* How to use Background steps to run single or multiple service instances
* How to combine Background steps with health checks for reliable pipeline execution
* Alternative approaches for managing dependencies in Harness CI

## Before you begin

* A [Harness CI pipeline](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/prep-ci-pipeline-components.md) with a [Build stage](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/set-up-build-infrastructure/ci-stage-settings.md)

You can run a single instance of a service or multiple instances. For examples of these configurations, go to:

* [Run a Sauce Connect Proxy service](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/ci-saucelabs-background-step.md)
* [Run a LocalStack service](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/ci-localstack-background-step.md)
* [Run multiple PostgreSQL instances](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/multiple-postgres.md)
* [Run Docker-in-Docker in a Kubernetes cluster build infrastructure](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/run-docker-in-docker-in-a-ci-stage.md)

Harness recommends [running health checks on background services](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/health-check-services.md) so that you can ensure the service is running before attempting to interact with it. This can prevent build failures when steps try to run commands on a service that is not yet running.

You can also manage dependencies through [caching and shared volumes](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/caching-ci-data/share-ci-data-across-steps-and-stages.md) or by installing dependencies in [Run steps](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/run-step-settings.md).

## Troubleshooting

<details>

<summary>Service is not ready when later steps try to connect</summary>

Add a health check Run step after each Background step that polls the service until it is ready. Go to [Run health checks on background services](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/health-check-services.md) for examples.

</details>

## Next steps

* Go to [Background step settings](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/background-step-settings.md) to configure a Background step
* Go to [Run health checks on background services](https://developer.harness.io/continuous-integration/use-harness-ci/use-harness-ci/manage-dependencies/health-check-services.md) to add health checks to your pipeline

{% @harness-feedback/feedback %}
