项目作者: containerbuildsystem

项目描述 :
Python library for parsing Dockerfile files.
高级语言: Python
项目地址: git://github.com/containerbuildsystem/dockerfile-parse.git
创建时间: 2015-06-18T15:59:46Z
项目社区:https://github.com/containerbuildsystem/dockerfile-parse

开源协议:BSD 3-Clause "New" or "Revised" License

下载


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

  1. pip install dockerfile-parse

From git

Clone this git repo and install using the python installer

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

Usage

  1. from pprint import pprint
  2. from dockerfile_parse import DockerfileParser
  3. dfp = DockerfileParser()
  4. dfp.content = """\
  5. From base
  6. LABEL foo="bar baz"
  7. USER me"""
  8. # Print the parsed structure:
  9. pprint(dfp.structure)
  10. pprint(dfp.json)
  11. pprint(dfp.labels)
  12. # Set a new base:
  13. dfp.baseimage = 'centos:7'
  14. # Print the new Dockerfile with an updated FROM line:
  15. print(dfp.content)