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*

Usage

This recipe has no required configuration options. It can be activated by adding a dependency on org.openrewrite:rewrite-docker in your build file or by running a shell command (in which case no build changes are needed):

  1. Add the following to your build.gradle file:
build.gradle
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}

rewrite {
activeRecipe("org.openrewrite.docker.search.FindExposedPorts")
setExportDatatables(true)
}

repositories {
mavenCentral()
}

dependencies {
rewrite("org.openrewrite:rewrite-docker:8.73.0")
}
  1. Run gradle rewriteRun to run the recipe.

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.