Skip to main content
Enforces maximum number of lines in a Dockerfile.
PropertyValue
SeverityError
CategoryMaintainability
DefaultEnabled (50 lines)

Description

Limits Dockerfile size to encourage modular builds. Enabled by default with a 50-line limit (P90 of analyzed public Dockerfiles). Large Dockerfiles are harder to maintain, review, and debug. This rule encourages:
  • Breaking complex builds into multi-stage patterns
  • Using base images for common dependencies
  • Keeping build logic modular

Options

OptionTypeDefaultDescription
maxinteger50Maximum lines allowed
skip-blank-linesbooleantrueExclude blank lines from count
skip-commentsbooleantrueExclude comment lines from count

Examples

Bad

# A 100+ line Dockerfile with everything in one file
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    # ... 50 more packages ...
    vim
# ... 80 more lines of setup ...

Good

# Base image with common dependencies
FROM myorg/base:1.0

# Application-specific setup only
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .
CMD ["python", "app.py"]

Configuration

[rules.tally.max-lines]
severity = "warning"
max = 100
skip-blank-lines = true
skip-comments = true

CLI Flags

tally lint --max-lines 100 --skip-blank-lines --skip-comments Dockerfile