Identifiersflags: g

Docker Image Tag

Match Docker image references with an explicit tag — e.g. nginx:1.21, mycorp/service:v2.3.1.

Try it in RegexPro →

Available in

JavaScript / ECMAScript code

jsJavaScript
const re = new RegExp("\\b[a-z0-9]+(?:[._\\-\\/][a-z0-9]+)*:[\\w.\\-]+\\b", "g");
const input = "FROM nginx:1.21";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));

Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).

Pattern

regexengine-agnostic
\b[a-z0-9]+(?:[._\-\/][a-z0-9]+)*:[\w.\-]+\b   (flags: g)

Raw source: \b[a-z0-9]+(?:[._\-\/][a-z0-9]+)*:[\w.\-]+\b

How it works

Image name is lowercase alphanumerics with optional . _ - / separators for registry paths. Tag follows the colon and can include letters, digits, dots, hyphens, and underscores.

Examples

Input

FROM nginx:1.21

Matches

  • nginx:1.21

Input

image: mycorp/service:v2.3.1

Matches

  • mycorp/service:v2.3.1

Input

ubuntu:latest

Matches

  • ubuntu:latest

Common use cases

  • Dockerfile auditing
  • CI pipeline image pinning
  • Vulnerability scanning input
  • Deployment manifest validation

Related patterns