用于dockerfile操作的python库
dockerfile-parse的Python项目详细描述
dockerfile解析
用于分析dockerfile文件的python库。
安装
来自Pypi
$ pip install dockerfile-parse
从git
克隆此git repo并使用python安装程序安装dockerfile parse:
$ git clone https://github.com/containerbuildsystem/dockerfile-parse.git
$ cd dockerfile-parse
$ sudo pip install .
用法
frompprintimportpprintfromdockerfile_parseimportDockerfileParserdfp=DockerfileParser()dfp.content="""\From baseLABEL 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)