Change Docker FROM

Apache 2.0

Change 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.

org.openrewrite.docker.ChangeFrom

Required

Glob pattern to match image names (without tag/digest).

Optional

Only match images with tags matching this glob pattern. If null, matches any tag or no tag.

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.

Only change images with this platform. If null, matches any platform.

The new image name. If null, preserves the existing name.

The new tag. If null, preserves the existing tag. If empty, removes the tag.

The new digest. If null, preserves the existing digest. If empty, removes the digest.

The new platform. If null, preserves the existing platform. If empty, removes the platform flag.

mod run . --recipe=org.openrewrite.docker.ChangeFrom \ -P oldImageName=ubuntu

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.