ShoupingShan / dockerfile-parse

Python library for parsing Dockerfile files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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)

About

Python library for parsing Dockerfile files.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 97.4%Language:Shell 2.6%