Crate dockerfile_parser

Source
Expand description

§Rust parser for Dockerfile syntax

A pure Rust library for parsing and inspecting Dockerfiles, useful for performing static analysis, writing linters, and creating automated tooling around Dockerfiles. It can provide useful syntax errors in addition to a full syntax tree.

§Quick start

use dockerfile_parser::Dockerfile;

let dockerfile = Dockerfile::parse(r#"
  FROM alpine:3.11 as builder
  RUN echo "hello world" > /hello-world

  FROM scratch
  COPY --from=builder /hello-world /hello-world
"#).unwrap();

for stage in dockerfile.iter_stages() {
  println!("stage #{}", stage.index);
  for ins in stage.instructions {
    println!("  {:?}", ins);
  }
}

Structs§

Enums§

Type Aliases§

  • A Dockerfile parsing Result.