docks is a Python framework designed to generate Markdown documentation for your Dockerfiles. It extracts key elements such as base images, ARG
/ENV
variables, exposed ports, and copied/added files, producing clear, structured documentation.
- Extracts:
- Base Images (
FROM
) - ARG/ENV Variables with optional docstrings and references
- Exposed Ports with descriptions
- Copied/Added Files (
COPY
/ADD
) with context
- Base Images (
- Outputs clean Markdown documentation for your Dockerfiles.
- Easy to use, modular, and extensible.
Install docks via Poetry or pip:
poetry add docks
pip install docks
The docks
CLI allows you to quickly generate Markdown documentation for a Dockerfile without writing code.
Here is all you have to do in order to generate the documentation.
docks <dockerfile> <output>
# e.g.
# docks myproject/Dockerfile myproject/dockerfile-doc.md
dockerfile
: Path to the Dockerfile to document.output
: Path to save the generated Markdown documentation.
You can also easily create the documentation programmatically via Python.
- Ensure you have a valid Dockerfile in your project.
- Run the following Python script
from docks.generate_doc import generate_markdown
# Path to your Dockerfile
dockerfile_path = "Dockerfile"
# Output Markdown file
output_path = "README.md"
# Generate documentation
generate_markdown(dockerfile_path, output_path)
- Include a block comment directly above the variable.
- Start the comment with the variable name followed by
:
for docstring extraction. - Optionally include a reference using
@ref:
.
# MY_VAR: Description of the variable.
# @ref: https://example.com/docs
ARG MY_VAR=default
Include a comment directly above the EXPOSE
command.
Start with the port number followed by :
for the description.
# 8080: Main HTTP server port
EXPOSE 8080
Add a comment directly above the COPY
or ADD
command for context.
# Copy application code to the container
COPY src/ /app/
Run tests with pytest:
pytest tests/
We welcome contributions! Please follow these steps:
- Fork the repository.
- Create a feature branch:
git checkout -b feature/<FEATURE_NAME>
. - Commit your changes:
git commit -m "Add feature"
. - Push the branch:
git push origin feature/<FEATURE_NAME>
. - Open a pull request.