CowboyLogic/ai-dev / skills/docker-image-management
docker-image-management
FlaggedGuide for creating, building, and managing Docker images and containers. Use this skill when working with Dockerfiles, containerization, image building, registry operations, container runtime, storage mounts, image security, Docker Compose, or any Docker-related task including optimization, debugging, and best practices.
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 5.1 KB |
| SKILL.md | skill md | 4.0 KB |
| references/build.md | markdown | 8.7 KB |
| references/docker-compose-examples.yml | config | 3.2 KB |
| references/dockerfile-templates.md | markdown | 2.6 KB |
| references/dockerignore-template | other | 2.0 KB |
| references/registry.md | markdown | 7.8 KB |
| references/run.md | markdown | 8.8 KB |
| scripts/docker-manage.sh | script | 4.8 KB |
README.md
View on GitHub# Docker Image Management Skill
This skill provides comprehensive guidance and tools for working with Docker containers and images. It covers everything from creating optimized Dockerfiles to managing container lifecycles and troubleshooting common issues.
## Files in This Skill
- **`SKILL.md`** — Core skill guide: decision table, principles, standard workflow, and debugging checklist
- **`references/build.md`** — Dockerfile instructions, multi-stage builds, BuildKit mounts, build cache, secrets, base image selection
- **`references/run.md`** — `docker run` options, networking, storage mounts, resource constraints, security capabilities, lifecycle
- **`references/registry.md`** — Tagging strategy, authentication, push/pull, Docker Hub, private registries, Docker Scout scanning
- **`references/dockerfile-templates.md`** — Ready-to-use Dockerfile templates for Node.js, Python, Go, and other runtimes
- **`references/docker-compose-examples.yml`** — Sample docker-compose configurations for multi-container architectures
- **`references/dockerignore-template`** — Language-specific `.dockerignore` patterns
- **`scripts/docker-manage.sh`** — Bash helper script for common Docker operations
## Quick Start
### 1. Basic Containerization
For a simple Node.js application:
1. Copy a Dockerfile template from `dockerfile-templates.md`
2. Create a `.dockerignore` file based on `dockerignore-template`
3. Build and run using the management script:
```bash
# Make script executable
chmod +x docker-manage.sh
# Build image
./docker-manage.sh build myapp:v1.0
# Run container
./docker-manage.sh run myapp:v1.0 myapp-container 3000:3000
```
### 2. Multi-Container Applications
For applications requiring multiple services:
1. Copy a docker-compose configuration from `docker-compose-examples.yml`
2. Customize environment variables and service configurations
3. Run the application:
```bash
docker-compose up -d
```
### 3. Development Workflow
For development environments:
1. Use the development docker-compose example
2. Mount source code as volumes for hot reloading
3. Access debug ports for debugging
## Common Use Cases
### Web Applications
- Single-page applications (React, Vue, Angular)
- API servers (Express, Flask, Django)
- Full-stack applications
### Microservices
- Service mesh configurations
- API gateways
- Database services
### Development Environments
- Consistent development setup across team
- Isolated dependencies
- Easy onboarding for new developers
### CI/CD Pipelines
- Automated testing environments
- Build artifacts
- Deployment containers
## Best Practices Summary
### Image Optimization
- Use multi-stage builds to reduce image size
- Choose appropriate base images (Alpine for smaller size)
- Clean up caches and temporary files
- Use .dockerignore to exclude unnecessary files
### Security
- Run containers as non-root users
- Keep base images updated
- Don't store secrets in images
- Scan images for vulnerabilities
### Performance
- Optimize layer caching order
- Minimize number of layers
- Use buildkit for faster builds
- Consider image size vs build time trade-offs
## Troubleshooting
### Common Issues
**Container exits immediately:**
- Check CMD/ENTRYPOINT in Dockerfile
- Verify application dependencies are installed
- Check for missing environment variables
**Port conflicts:**
- Use different host ports
- Stop conflicting containers
- Check `docker ps` for running containers
**Permission denied:**
- Ensure proper user setup in Dockerfile
- Check file permissions on host
- Avoid running containers as root when possible
**Slow builds:**
- Optimize .dockerignore
- Reorder COPY commands for better caching
- Use multi-stage builds
- Enable BuildKit
### Debug Commands
```bash
# View container logs
docker logs <container_name>
# Execute commands in running container
docker exec -it <container_name> /bin/bash
# Inspect container configuration
docker inspect <container_name>
# Check container resource usage
docker stats <container_name>
```
## Integration with Development Workflow
### Version Control
- Commit Dockerfile and docker-compose.yml
- Consider committing docker-manage.sh for team use
- Use .dockerignore to exclude build artifacts
### CI/CD Integration
- Use GitHub Actions or other CI systems
- Build images automatically on commits
- Run tests in containers
- Deploy using container orchestration
### Team Collaboration
- Document container setup in project README
- Share common patterns and templates
- Establish naming conventions for images and containers
## Additional Resources
- [Docker Documentation](https://docs.docker.com/)
- [Docker Best Practices Guide](https://docs.docker.com/develop/dev-best-practices/)
- [Docker Compose Documentation](https://docs.docker.com/compose/)
- [Docker Security Best Practices](https://docs.docker.com/develop/security-best-practices/)
## Contributing
When contributing to this skill:
1. Test all examples and scripts
2. Update documentation for new features
3. Follow the established patterns and conventions
4. Add examples for new use cases
5. Validate with the skill validation script from the skill-creator skillRelated skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |