Skip to main content

Find exposed ports

org.openrewrite.docker.search.FindExposedPorts

Find all EXPOSE instructions in Dockerfiles and report the exposed ports.

Recipe source

GitHub: FindExposedPorts.java, Issue Tracker, Maven Central

This recipe is available under the Apache License Version 2.0.

Options

TypeNameDescriptionExample
StringportPatternOptional. A glob pattern to filter ports. For example, '80*' to find ports starting with 80. If not specified, all EXPOSE instructions are matched.80*

Example

Parameters
ParameterValue
portPatternnull
Before
FROM nginx:latest
EXPOSE 80
After
FROM nginx:latest
~~(80)~~>EXPOSE 80

Usage

This recipe has no required configuration options. Users of Moderne can run it via the Moderne CLI.

You will need to have configured the Moderne CLI on your machine before you can run the following command.

shell
mod run . --recipe FindExposedPorts

If the recipe is not available locally, then you can install it using:

mod config recipes jar install org.openrewrite:rewrite-docker:8.73.2

See how this recipe works across multiple open-source repositories

Run this recipe on OSS repos at scale with the Moderne SaaS.

The community edition of the Moderne platform enables you to easily run recipes across thousands of open-source repositories.

Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.

Data Tables

Docker exposed ports

org.openrewrite.docker.table.ExposedPorts

Records all ports exposed in EXPOSE instructions in Dockerfiles.

Column NameDescription
Source fileThe Dockerfile containing the EXPOSE instruction.
Stage nameThe build stage name if the EXPOSE is in a named stage.
PortThe port number or range (e.g., '80' or '8000-8100').
ProtocolThe protocol if specified (tcp or udp), null if not specified.