# Re-build automatically when new image is available on DockerHub

**URL:** <https://discuss.circleci.com/t/re-build-automatically-when-new-image-is-available-on-dockerhub/50350>\
**Category:** Build Environment\
**Created:** [January 29, 2024, 11:41pm UTC](https://discuss.circleci.com/t/re-build-automatically-when-new-image-is-available-on-dockerhub/50350 "2024-01-29T23:41:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastian-lerner](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/sebastian-lerner/32/27833_2.png) [@sebastian-lerner](https://discuss.circleci.com/u/sebastian-lerner)\
**Post date:** [January 29, 2024, 11:41pm UTC](https://discuss.circleci.com/t/re-build-automatically-when-new-image-is-available-on-dockerhub/50350/1 "2024-01-29T23:41:10Z")

</div>

**What**

Software teams often have code that depends on a Docker image that is owned by a separate team within the same company. **A common pain point** with this setup is that staying up-to-date by using the latest image can come at the cost of instability if the newest version does not play nicely with the existing code.

To avoid this instability, CircleCI’s [inbound webhooks](https://discuss.circleci.com/t/trigger-pipelines-from-anywhere-inbound-webhooks-now-in-preview/49864) gives users a way to “listen” for when a new image that you depend on is published so that your code can validate compatibility with the new image & get re-packaged with the new image if compatible.

**Why?**

This type of automation saves you and your team time by converting a tedious manual chore into an automated process. Any time there’s a new image to consume, you’ll immediately know if it can be incorporated or if it needs further investigation.

**Quick-start**

Navigate to [app.circleci.com](http://app.circleci.com) → “ **Projects** ” → “ **Project Settings** ” → ” **Triggers** ” → ” **Add Trigger** ”

 ![](https://global.discourse-cdn.com/circleci/original/3X/e/8/e8fa7971fb4dd693994cc36cd947e8b0d0c6fc71.png)

Ensure “ **Inbound Webhook** ” is selected

 ![](https://global.discourse-cdn.com/circleci/original/3X/c/a/ca6cc87965068f163df12f4b7bcba6baed674f26.png)

Give the “inbound webhook” a human-readable “ **Source** ”, “ **Description** ”, and **Configuration File Path**. Click “Next” and write down the “ **Webhook URL** ” and “ **Secret** ” somewhere where they can accessed again.

In this example, we’re using a configuration file that is _different than our typical “build-test-deploy” CI pipeline_. In our repository, we still have a `.circleci/config.yml` that uses a pinned image version to “build-test-deploy” on every push, but we also have created a `.circleci/listen_upstream_image.yml` file that has a pipeline which:

- Checks out code from repository
- Pulls the new image that just got pushed
- Authenticates the new image & performs an image scan
- Rebuilds the repository using the new upstream image
- Runs a set of tests against the newly built artifact
- Sends a custom Slack notification to my team

 ![Screenshot 2024-01-29 at 6.27.09 PM](https://global.discourse-cdn.com/circleci/original/3X/0/9/098e7116298c2dd03d8ad595d05eb95f70a388d7.png)

Navigate to the DockerHub registry that your software depends on. Click on the “ **Webhooks** ” tab.

 ![webhooks_tab](https://global.discourse-cdn.com/circleci/original/3X/0/1/01bde121ac2898647203e8e142d9d07e9a349fe2.png)

Paste the URL that you copied and stored earlier for your CircleCI inbound webhook.

 ![create_docker_webhook](https://global.discourse-cdn.com/circleci/original/3X/a/2/a20681f9f49e77e74dde7231a7dca7fc84a8feeb.png)

 ![](https://global.discourse-cdn.com/circleci/original/3X/7/5/75255e169f4ccaf3fb73435c29c6c6602f7a0609.png)

Click “ **Create** ”. At this point, when a new image is pushed to that registry…

 ![](https://global.discourse-cdn.com/circleci/original/3X/8/c/8c0d4a7ab5f49c09b81087fab686a78991406f51.png)

…a pipeline will run on CircleCI that runs the configuration that you specified:

 ![](https://global.discourse-cdn.com/circleci/original/3X/0/f/0fd139aa00925f1e8424442f2588c4ce9eed7f22.png)
