Change Docker FROM
Recipe ID
org.openrewrite.docker.ChangeFromArtifact
org.openrewrite:rewrite-dockerChange the base image in a Dockerfile FROM instruction. Each * in an old* glob is a positional capture; $N in the paired new* substitutes capture N. $0 substitutes the full original value; \$ is a literal dollar.
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.docker.ChangeFrom --recipe-option "oldImageName=ubuntu"If the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite:rewrite-docker:8.88.0Options
| Name | Type | Description |
|---|---|---|
oldImageNamerequired | String | Glob pattern to match image names (without tag/digest). e.g. ubuntu |
oldTag | String | Only match images with tags matching this glob pattern. If null, matches any tag or no tag. e.g. 20.* |
oldDigest | String | Only match images with digests matching this glob pattern. If null, matches any digest or no digest. If empty (""), matches only images that have no digest, which is useful for skipping digest-pinned FROMs so deliberate pins are left untouched.e.g. sha256:* |
oldPlatform | String | Only change images with this platform. If null, matches any platform. e.g. linux/amd64 |
newImageName | String | The new image name. If null, preserves the existing name. e.g. ubuntu |
newTag | String | The new tag. If null, preserves the existing tag. If empty, removes the tag. e.g. 22.04 |
newDigest | String | The new digest. If null, preserves the existing digest. If empty, removes the digest. e.g. sha256:abc123... |
newPlatform | String | The new platform. If null, preserves the existing platform. If empty, removes the platform flag. e.g. linux/arm64 |
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats