skillfed

dockerfile

Parse a dockerfile into a high-level representation using the official go parser.

dockerfile v3.4.0 358.8K downloads/30d#7,260 on PyPI105
Permissive license MIT Abandoned released

What it is and what it does

dockerfile is a Python wrapper around Docker's official Dockerfile parser, written in Go. It exposes three main functions: all_cmds() lists valid Dockerfile commands, parse_file() parses a Dockerfile from disk, and parse_string() parses Dockerfile syntax from a string. Each returns a tuple of Command objects with structured fields (cmd, sub_cmd, json flag, original text, line number, flags, and parsed values).

The package is useful for tools that need to analyze or manipulate Dockerfile content programmatically. It has no runtime dependencies and handles parsing errors with specific exception types (GoIOError for file access, GoParseError for syntax). The repository is now archived and unmaintained, though it remains functional for current Python versions.

Use it for:

  • Analyze Dockerfile structure in CI/CD pipelines to validate layer counts, base images, or security patterns.
  • Extract environment variables, exposed ports, or entrypoint commands from Dockerfiles for documentation or compliance scanning.
  • Build linting or static analysis tools that inspect Dockerfile syntax and report violations.
  • Programmatically modify or generate Dockerfiles by parsing existing ones and reconstructing them with changes.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses Dockerfile syntax into structured Python objects using the official Docker parser, exposing commands, flags, and values for programmatic inspection.

Yes, if you need reliable Dockerfile parsing and can accept that the package is archived. The MIT license is permissive, install friction is manageable with prebuilt wheels, and there are no known vulnerabilities. However, be aware that the repository is no longer maintained—if Docker's parser evolves significantly or you encounter edge cases, upstream fixes are unlikely. For new projects, verify that the parsing behavior matches your current Docker version.

Install

dockerfile on PyPI

pip

pip install dockerfile

uv

uv add dockerfile

poetry

poetry add dockerfile

Installing dockerfile

Before you install

Medium install friction due to compiled extension (requires Go compiler when building from source), but prebuilt wheels are available for common platforms. Repository is archived and unmaintained as of 587 days since last release, though the latest version was released on 2025-01-04.

License in practice

MIT license is permissive and poses no restrictions on commercial or private use, modification, or redistribution.

Quickstart

pip install dockerfile

import dockerfile

cmds = dockerfile.parse_file('Dockerfile')
for cmd in cmds:
    print(cmd.cmd, cmd.value)

Requires Python >= 3.9. Building from source requires a Go compiler; prebuilt wheels are available for Linux x86_64, macOS (x86_64 and ARM64), and Windows x64.

Verify before relying

  • Whether the archived repository will continue to receive security updates or bug fixes if Docker's parser changes significantly.
  • Performance characteristics when parsing very large or complex Dockerfiles.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance abandoned — 587 days since the last release
Last repo commit (repository archived)
First released
Downloads 358,768/month — #7,260 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: dockerfile-3.4.0-cp39-abi3-macosx_13_0_x86_64.whl; dockerfile-3.4.0-cp39-abi3-macosx_14_0_arm64.whl; dockerfile-3.4.0-cp39-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.whl; dockerfile-3.4.0-cp39-abi3-win_amd64.whl

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

dockerfile parser pythonparse dockerfile syntaxdocker container definition analysisdockerfile command extractiondockerfile ast representationdocker build file parsingcontainerfile syntax analysis
dockerfile-parsingdocker-toolingarchived

More Build Tools packages