# Upgrade the Base Images in Your Dockerfiles Every Week

Yes. An agent moves each Dockerfile to a supported base image, fixes what the new runtime breaks, builds and runs the stack, and opens one pull request a week.

[Run this on Rush](https://cloud.getrush.ai/run/upgrade-base-images/docker/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the repository into its own cloud sandbox and inventories every `FROM` line before changing one. In a repository like dockersamples/example-voting-app that is five Dockerfiles for three services and two tools: `vote/Dockerfile` on `python:3.11-slim` with a `base`, `dev` and `final` stage, `result/Dockerfile` on `node:18-slim`, `worker/Dockerfile` building on `mcr.microsoft.com/dotnet/sdk:7.0` and running on `mcr.microsoft.com/dotnet/runtime:7.0`, `seed-data/Dockerfile` on `python:3.9-slim`, and `result/tests/Dockerfile` on `node:8.9-slim`. It also reads the images the repository pulls rather than builds, `redis:alpine` and `postgres:15-alpine` in `docker-compose.yml`, `docker-stack.yml` and `k8s-specifications/`, because a database major bump is a different kind of change and is reported rather than made.

For each image the agent checks the runtime's own release schedule and the tags on Docker Hub, and sorts the lines into three groups. Node 18 and .NET 7 are both past their end of support, so `result` and `worker` get a supported major; Python 3.11 is still supported, so `vote` moves to the current slim tag within what Flask, Redis and gunicorn in `vote/requirements.txt` accept, and the unpinned requirements are called out in the pull request. The `worker` bump is more than a tag change: `worker/Worker.csproj` declares `<TargetFramework>net7.0</TargetFramework>`, so the agent moves it to the matching `net8.0` and checks that the three pinned packages, `StackExchange.Redis 2.2.4`, `Npgsql 4.1.9` and `Newtonsoft.Json 13.0.1`, restore against it. The `node:8.9-slim` test image with `phantomjs-prebuilt` is reported as unmaintained rather than bumped, since PhantomJS has no supported successor on a new Node.

Each change is its own commit, so a reviewer can drop one bump by reverting one commit. The sandbox has no Docker, so the agent installs it first with `sudo apt-get install -y docker.io` and starts `dockerd`, then runs `docker build` for every changed Dockerfile and, because the `docker.io` package ships `docker-compose` v1 rather than the `docker compose` plugin, runs `docker-compose up -d` with the repository's `docker-compose.yml`, waits for the `curl -f http://localhost` health check on `vote` and the `/healthchecks/postgres.sh` and `redis.sh` checks on the databases, posts a vote on port `8080` and reads the result page on port `8081`. The build logs and the compose status go into the pull request as the proof that the new runtimes run this code.

The agent also reads what else depends on the old versions. The `worker` workflow carries a comment that `arm/v7` did not build on an older .NET, and the Dockerfile builds on `BUILDPLATFORM` and targets `TARGETARCH`, so the agent keeps that structure and says in the pull request that the three-platform build in `call-docker-build-worker.yaml` is the one thing the sandbox could not reproduce on a single architecture. `.github/dependabot.yml` covers only `github-actions`, monthly, so the agent proposes a `docker` entry per directory in a note rather than adding one, leaving that choice to the reviewer.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Upgrade the base images in this repository's Dockerfiles. Read every Dockerfile and every compose, stack and Kubernetes file that names an image first. For each FROM line, check the runtime's support status and the available tags; move runtimes that are out of support to a supported major and others to the current patch tag. Make the code changes a new runtime needs, such as the target framework in a .csproj, and leave database images alone but report them. One commit per image. Install Docker in the sandbox, build every changed image, start the stack with the repository's compose file and exercise it, and put the build and run output in the pull request. Open one pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is one pull request with one commit per image: `vote/Dockerfile`, `result/Dockerfile`, `worker/Dockerfile` with `worker/Worker.csproj`, and `seed-data/Dockerfile`, each commit message naming the old and new tag and why. The description has a table of every `FROM` line in the repository with its status, the `docker build` output for each changed image, and the `docker-compose` run with the health checks passing and the vote recorded on the result page.

Images the agent chose not to touch are in the same description with the reason: `postgres:15-alpine` and `redis:alpine` because a database major needs a data migration plan, and `result/tests/Dockerfile` because its PhantomJS test runner has no supported path. Nothing is pushed to a registry; the existing build workflows run on the pull request and produce the multi-platform images as they do for any change.

Before merging, a reviewer reads the `worker` commit most closely, since it changes code and not just a tag, confirms the three-platform build in CI went green, and decides whether to adopt the Dependabot `docker` entries the description proposes so patch tags move without a weekly run.

## Run it on every Monday morning

Create an automation in the Project with this prompt and a `schedule` trigger (`cron` `0 9 * * 1` in your `timezone`). Each week the run opens one pull request when a tag moved or a runtime fell out of support, and none when nothing changed. Because each image is its own commit, holding one back is a revert of one commit, not a rewrite of the pull request.

To get the link where your team reads, start the weekly run from your own scheduler instead with `POST /o/{org}/sessions`, this body and an API key that has a `webhook_url`: Rush POSTs `run.completed` with the `session_url` when the turn ends, and a handler on your side reads the pull request link from it. Send a `request_id`, a UUID, so a retried start returns the run it already began.

## Why run it on Rush?

A base-image bump is cheap to type and expensive to trust: the tag changes in a second, and whether the Node service still starts or the .NET worker still restores its packages is only known after a build and a run. The agent does the build and the run in its own sandbox with Docker installed for the occasion, and the pull request carries that output, so the review is of evidence rather than of a one-line diff.

Doing this weekly on a laptop means someone pulls five base images, builds three services and starts a database every Monday. On Rush that happens in a disposable sandbox with nothing left behind, several repositories at once if you have them, and the full command record stays with each run for as long as the pull request is open.

## Frequently asked questions

### Why not just use Dependabot's docker ecosystem?

Use both. Dependabot moves a `FROM` tag and opens a pull request, but it does not change `Worker.csproj` when the .NET major moves, does not build the image and does not start the stack. The agent does those and reports which images Dependabot could then keep on patch tags; the pull request proposes the `docker` entries for `.github/dependabot.yml`.

### Will it bump my database images?

No. `postgres:15-alpine` and `redis:alpine` are listed in the pull request with their status, but a Postgres major needs a data migration plan and a maintenance window, which is a decision for you. A patch tag for an already-pinned database image can be bumped on request in a follow-up.

### How does it know a runtime is out of support?

It reads the runtime's published release schedule and the tags currently offered on Docker Hub, and quotes both in the pull request for each `FROM` line. Where a runtime is supported but behind, it moves to the current patch tag only.

### What if the new runtime breaks the service?

The agent builds and runs the stack before opening the pull request. If a service fails to build or its health check does not pass on the new image, the agent either fixes the cause and shows the fix in its own commit, or leaves that image on its old tag and explains the failure with the log, rather than opening a pull request that does not build.

## More Docker jobs

- [Write Container Structure Tests for Docker Images](https://getrush.ai/run/write-container-structure-tests/docker/)
- [Add a Docker Bake File to Build Every Image in a Repository](https://getrush.ai/run/add-docker-bake/docker/)
- [Add a GitHub Actions Workflow That Builds a Docker Image and Pushes It to GHCR](https://getrush.ai/run/add-docker-publish-workflow/docker/)

## More jobs like this: Upgrade dependencies weekly

- [Upgrade Bootstrap 4 to Bootstrap 5 and Remove jQuery](https://getrush.ai/run/upgrade-bootstrap/bootstrap/)
- [Upgrade CakePHP to the Next Minor Version](https://getrush.ai/run/upgrade-cakephp/cakephp/)
- [Upgrade Cargo Dependencies Weekly for an Actix Web API](https://getrush.ai/run/upgrade-cargo-dependencies/actix/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
