A powerful command-line utility for analyzing, managing, and editing Docker Compose files with rich terminal output and advanced features.
- Service Management: List, view, edit, duplicate, copy, rename, remove, and create services
- Port Analysis: Find duplicate ports, check port usage across services
- Resource Inspection: View volumes, devices, hostnames, and port configurations
- Dockerfile Integration: Read, edit, copy, and set Dockerfiles associated with services
- Entrypoint Management: View and edit entrypoint scripts
- File Management: Read and edit files referenced in Dockerfile COPY commands
- Rich Terminal Output: Colorized syntax highlighting and formatted display
- Pattern Matching: Support for wildcards, regex, and substring matching for service names
- File Caching: Intelligent caching system for improved performance
- Version Support: Display script version from
__version__.py
- Python 3.6+
- Required Python packages:
pip install pyyaml rich pydebugger configset rich-argparse clipboard
- Clone or download the
ddf.py
script - Make it executable (Linux/macOS):
chmod +x ddf.py
- Create a configuration file
ddf.ini
in the same directory (optional; auto-created if missing) - Add to your PATH for global access (optional)
Create a ddf.ini
file in the same directory as ddf.py
:
[docker-compose]
file = /path/to/your/docker-compose.yml
root_path = /path/to/your/project/root
[editor]
names = nvim,nano,vim
file
: Path to the default Docker Compose YAML file.root_path
: Project root directory (defaults toc:\PROJECTS
on Windows if exists, else current directory).names
: Comma-separated list of preferred editors.
python ddf.py [service_name] [options]
Option | Description |
---|---|
-c, --file FILE |
Path to Docker Compose YAML file |
-l, --list |
List ports for the specified service |
-d, --detail |
Show full configuration for the service |
-f, --find PORT |
Find which services use a specific port |
-p, --port PORT |
Check if a port is duplicated across services |
-D, --device |
Show devices for service(s) |
-vol, --volumes |
Show volumes for service(s) |
-P, --list-port |
List all ports for a service (same as -l ) |
-L, --list-service-name |
List all service names, optionally with -F filter |
-r, --dockerfile |
Read and display Dockerfile for service |
-e, --edit-dockerfile |
Edit Dockerfile for service (creates new if missing) |
-sd, --set-dockerfile PATH |
Set Dockerfile path for service |
-E, --edit-service |
Edit service configuration |
-en, --entrypoint |
Read and display entrypoint script |
-ed, --edit-entrypoint |
Edit entrypoint script |
-cs, --copy-service |
Copy service configuration to clipboard |
-cd, --copy-dockerfile |
Copy Dockerfile content to clipboard |
-dd, --duplicate-service NEW_NAME |
Duplicate service with new name |
-rn, --rename-service NEW_NAME |
Rename service |
-rm, --remove-service |
Remove service from compose file |
-a, --all |
Show all services' details with -f |
-nl, --no-line-numbers |
Disable line numbers in syntax highlighting |
-hn, --hostname |
Show hostname(s) for service(s) |
-n, --new |
Create a new service |
-F, --filter PATTERN |
Filter services by regex, wildcard, or substring |
-v, --version |
Show script version |
-ef, --edit-file FILENAME |
Edit file referenced in Dockerfile COPY command |
-rf, --read-file FILENAME |
Read file referenced in Dockerfile COPY command |
--theme THEME |
Set syntax highlighting theme (default: fruity) |
python ddf.py -L
python ddf.py -L -F web* app
python ddf.py webapp -d
python ddf.py
python ddf.py -f 8080
python ddf.py -p 3000
python ddf.py webapp -l
python ddf.py web -vol
python ddf.py webapp -hn
python ddf.py webapp -E
python ddf.py webapp -r
python ddf.py webapp -e
python ddf.py webapp -sd ./custom/Dockerfile
python ddf.py webapp -ed
python ddf.py webapp -rf entrypoint.sh
python ddf.py webapp -ef config.conf
python ddf.py new-service -n
python ddf.py webapp -dd webapp-staging
python ddf.py webapp -rn webapp-prod
python ddf.py webapp -cs
python ddf.py webapp -cd
python ddf.py webapp -rm
python ddf.py -v
DDF supports flexible service name matching:
- Exact match:
webapp
- Wildcard:
web*
(matches webapp, webserver, etc.) - Substring:
app
(matches webapp, myapp, etc.) - Regex: Use with
-F
(e.g.,-F '^web.*$'
)
- Automatically locates Dockerfiles based on service build context
- Resolves entrypoint scripts from Dockerfile COPY instructions
- Supports relative and absolute paths
- Creates new Dockerfiles if missing when editing
- Syntax-highlighted YAML, Dockerfile, and script content
- Colorized port conflict detection
- Formatted service listings with visual indicators
- File content caching based on SHA256 hashes
- Improved performance for repeated operations
- Automatic cache invalidation on file changes
- Default Docker Compose file:
docker-compose.yml
in current directory orc:\PROJECTS\docker-compose.yml
- Default project root:
c:\PROJECTS
(if exists on Windows), else current directory - Default editors:
nvim
,nano
,vim
The utility tries editors in this order:
- Custom editors from
ddf.ini
nano
nvim
vim
DDF provides comprehensive error handling for:
- Missing or invalid YAML files
- Non-existent services
- File permission issues
- Invalid port configurations
- Missing Dockerfiles or entrypoint scripts
- Editor availability
webapp/ports/8080/tcp --> api/ports/8080/tcp
Ports for service 'webapp':
- 8080:80
- 443:443
webapp:
volumes:
- ./src:/app/src
- ./logs:/var/log/app
- webapp: hostname: app.example.com
- Editor detection is platform-dependent
- Some features require specific Docker Compose file structures
- File paths in COPY commands must be resolvable relative to build context
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source. Please check the license file for details.
For issues, feature requests, or questions:
- Check existing documentation
- Review error messages carefully
- Ensure proper YAML syntax in Docker Compose files
- Verify file permissions and paths
- Use
-L
to list all services before working with specific ones - Pattern matching is case-sensitive
- Always backup your Docker Compose files before editing
- Use the duplicate feature to create staging/development variants
- The clipboard copy feature is useful for sharing configurations
- Use
-F
with regex for precise service filtering