skillfed

dockerfile-parse

Python library for Dockerfile manipulation

dockerfile-parse v2.0.1 11.6M downloads/30d#1,375 on PyPI142
Permissive license BSD DORMANT released

What it is and what it does

dockerfile-parse is a Python library that reads and parses Dockerfile files into a structured representation, exposing properties like base image, labels, and user directives for programmatic inspection and modification. It has no runtime dependencies and supports Python 3.6 through 3.11, making it lightweight to integrate into build tooling, container orchestration systems, or CI/CD pipelines that need to reason about or rewrite Dockerfiles.

The library is in Production/Stable status and has been maintained since 2015, though recent activity is minimal. It is suitable for tasks like extracting metadata from Dockerfiles, validating structure, or generating modified versions with updated base images or labels. The permissive BSD license allows use in both open and closed projects.

Use it for:

  • Extract base image, labels, and user directives from existing Dockerfiles for inventory or compliance auditing
  • Programmatically update a Dockerfile's base image across a fleet of build configurations
  • Validate Dockerfile structure and syntax before passing it to a build system
  • Generate or transform Dockerfiles in build automation tools that need to inject environment variables or change layers

Worth the install?

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

Parses and manipulates Dockerfile files programmatically, allowing you to read, analyze, and modify Dockerfile structure and content through a Python API.

Yes, if you need to parse or modify Dockerfiles in Python code. Low install friction, no dependencies, and stable API make it a straightforward choice for build tooling. Dormant maintenance is acceptable for a mature, narrow-scope library, but verify that its parser handles your target Dockerfile syntax before committing to it in a critical pipeline.

Install

dockerfile-parse on PyPI

pip

pip install dockerfile-parse

uv

uv add dockerfile-parse

poetry

poetry add dockerfile-parse

Installing dockerfile-parse

Before you install

Low install friction with no runtime dependencies. Maintenance is dormant—last release was 2023-07-18 and no commits since 2024-08-12—but the package is marked Production/Stable and has been in use since 2015, so it is unlikely to require active development.

License in practice

BSD license is permissive, allowing commercial and private use with minimal restrictions; you must include a copy of the license and copyright notice.

Quickstart

pip install dockerfile-parse

from dockerfile_parse import DockerfileParser

dfp = DockerfileParser()
dfp.content = "FROM base\nLABEL foo=\"bar\"\nUSER me"
print(dfp.baseimage)
dfp.baseimage = 'centos:7'
print(dfp.content)

Verify before relying

  • Whether the parser handles all Dockerfile syntax variations and edge cases introduced in recent Docker versions
  • Whether dormant maintenance poses a risk if Docker's Dockerfile format evolves significantly

Package facts

License BSD (permissive)
Python support supports the current Python release (>=3.6)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance dormant — 1,123 days since the last release
Last repo commit
First released
Downloads 11,634,782/month — #1,375 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: dockerfile_parse-2.0.1-py2.py3-none-any.whl

Development Status :: 5 - Production/StableEnvironment :: Other EnvironmentIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: Libraries :: Python Modules

Tags

dockerfile parsingparse dockerfile pythondockerfile manipulationread dockerfile structuredockerfile analysis librarymodify dockerfile contentdockerfile ast parser
dockerfilecontainer-buildparsing

More Python Modules packages