Skip to main content

Python library for Dockerfile manipulation

Project description

dockerfile-parse

unittests status badge coveralls status badge lgtm python badge lgtm alerts badge linters status badge

Python library for parsing Dockerfile files.

Installation

From PyPI

pip install dockerfile-parse

From git

Clone this git repo and install using the python installer

git clone https://github.com/containerbuildsystem/dockerfile-parse.git
cd dockerfile-parse
sudo pip install .

Usage

from pprint import pprint
from dockerfile_parse import DockerfileParser

dfp = DockerfileParser()
dfp.content = """\
From  base
LABEL foo="bar baz"
USER  me"""

# Print the parsed structure:
pprint(dfp.structure)
pprint(dfp.json)
pprint(dfp.labels)

# Set a new base:
dfp.baseimage = 'centos:7'

# Print the new Dockerfile with an updated FROM line:
print(dfp.content)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dockerfile-parse-2.0.1.tar.gz (24.6 kB view hashes)

Uploaded Source

Built Distribution

dockerfile_parse-2.0.1-py2.py3-none-any.whl (14.8 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page