Parse a dockerfile into a high-level representation using the official go parser.
Project description
dockerfile
The goal of this repository is to provide a wrapper around docker/docker's parser for dockerfiles.
python library
Installation
This project uses setuptools-golang when built from source. To build from source you'll need a go compiler.
If you're using linux and sufficiently new pip (>=8.1) you should be able to just download prebuilt manylinux1 wheels.
pip install dockerfile
Usage
There's three api functions provided by this library:
dockerfile.all_cmds()
List all of the known dockerfile cmds.
>>> dockerfile.all_cmds()
('add', 'arg', 'cmd', 'copy', 'entrypoint', 'env', 'expose', 'from', 'healthcheck', 'label', 'maintainer', 'onbuild', 'run', 'shell', 'stopsignal', 'user', 'volume', 'workdir')
dockerfile.parse_file(filename)
Parse a Dockerfile by filename.
Returns a tuple
of dockerfile.Command
objects representing each layer of
the Dockerfile.
Possible exceptions:
dockerfile.GoIOError
: The file could not be opened.dockerfile.ParseError
: The Dockerfile was not parseable.
>>> pprint.pprint(dockerfile.parse_file('testfiles/Dockerfile.ok'))
(Command(cmd='from', sub_cmd=None, json=False, original='FROM ubuntu:xenial', start_line=1, flags=(), value=('ubuntu:xenial',)),
Command(cmd='cmd', sub_cmd=None, json=True, original='CMD ["echo", "hi"]', start_line=2, flags=(), value=('echo', 'hi')))
dockerfile.parse_string(s)
Parse a dockerfile using a string.
Returns a tuple
of dockerfile.Command
objects representing each layer of
the Dockerfile.
Possible exceptions:
dockerfile.ParseError
: The Dockerfile was not parseable.
>>> dockerfile.parse_string('FROM ubuntu:xenial')
(Command(cmd='from', sub_cmd=None, json=False, original='FROM ubuntu:xenial', start_line=1, flags=(), value=('ubuntu:xenial',)),)
go library
Slightly more convenient than the api provided by docker/docker? Might not be terribly useful -- the main point of this repository was a python wrapper.
Installation
go get github.com/asottile/dockerfile
Usage
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for dockerfile-2.2.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e02371f250ee5d1c34e4d90bd6b369c661d4133d83808e9d7d92d2b0081be0b1 |
|
MD5 | 6cc9b4877645eab18cf7126c6319df8d |
|
BLAKE2b-256 | 0f4f5dcd88fcdded757ab7ca6d55f07094bd7dc702c3bb7668301b57f05b9171 |
Hashes for dockerfile-2.2.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75e8aadd5b98451d3612fd3c53d034996472b39a4e1851eaf4ca7b0a98d4e221 |
|
MD5 | 88e9e10ae09d48b02a0ded599325fe2a |
|
BLAKE2b-256 | 3f5e593a793e4c080106d8b061f757092f4b059aaa10b79437bdbaf1b57c84c1 |
Hashes for dockerfile-2.2.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f16b3ce75022d63f0527c082589aef9ee01ec3ba90bc4af031a17e473a0e86d |
|
MD5 | 287e8e090b57b22f206c857086aa4470 |
|
BLAKE2b-256 | ee585012ed3e697b6a6ed4da07df8ac80ac792b09494e08b6aafdf85614f7c25 |
Hashes for dockerfile-2.2.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81bb134ae93dc637772b8bc6ae861a16dc29aeb09f8e92896629df8995be2388 |
|
MD5 | 5318ccc46d578996e097f975a006de1f |
|
BLAKE2b-256 | 84e193b48e110f4654c934eb3751185612b830587d5864b7b0fbed3e6a71a462 |
Hashes for dockerfile-2.2.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c1237b34f79e938310000c30e3455327e09c95fc8e706dba542f512a16742e7 |
|
MD5 | 4c62cca830b788417d28e6dcd45b5586 |
|
BLAKE2b-256 | 410dd3daeb6d8c88324e8c9e38a9a386c2335168aa1632b21c8490d78ffe3cad |
Hashes for dockerfile-2.2.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 339babc676e366f6c5e9b1448e0197747b6f48c2bca1c24f2e1665300141e35e |
|
MD5 | 58f67eaf0fe6e97c9316b2beb96a9281 |
|
BLAKE2b-256 | b0371b29f2f25bd612ff76c27972ea4d2864079426d1d308114a5f574dd3ca3a |
Hashes for dockerfile-2.2.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d212e4d3e35907ac73ed6dbe2aafbee76af39cf423863a72e7318a68d73dae31 |
|
MD5 | 8af0988ba4f8335e0a30a4f24d81be9d |
|
BLAKE2b-256 | 973e71ccf9921ebaa944684e3f837ee1c2739f0a66607d0e122777e5fedad36f |
Hashes for dockerfile-2.2.0-cp27-cp27m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0130bdbee8b70d0067666ef5a423f0c5582cec78386d3137824f2d58e20af65 |
|
MD5 | e2cfc0d4890179c3874d5b76fdba9b00 |
|
BLAKE2b-256 | 936a37610ecb90a0a36ceaa631118acfb28320cf27b20139c03703bc21567f62 |