docker-database
Configure database containers with security, persistence, and health checks
Best use case
docker-database is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Configure database containers with security, persistence, and health checks
Teams using docker-database should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/docker-database/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How docker-database Compares
| Feature / Agent | docker-database | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Configure database containers with security, persistence, and health checks
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Docker Database Configuration Skill
## Overview
This skill configures database containers following best practices for:
- Security (passwords, network isolation)
- Persistence (named volumes)
- Health checks
- Initialization scripts
- Backup and restore
## Supported Databases
- PostgreSQL
- MySQL/MariaDB
- MongoDB
- Redis
## Process
### 1. Consult Documentation
Read `05-databases.md` for:
- Image versions
- Environment variables
- Health check configurations
- Volume paths
- Initialization patterns
### 2. Generate Configuration
## PostgreSQL Configuration
```yaml
services:
postgres:
image: postgres:16-alpine
container_name: postgres
restart: unless-stopped
shm_size: 256mb
environment:
POSTGRES_USER: ${DB_USER:-appuser}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME:-appdb}
volumes:
- postgres_data:/var/lib/postgresql/data
- ./init-scripts:/docker-entrypoint-initdb.d
ports:
- "127.0.0.1:5432:5432"
networks:
- database
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-appuser} -d ${DB_NAME:-appdb}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
volumes:
postgres_data:
networks:
database:
internal: true
```
## MySQL Configuration
```yaml
services:
mysql:
image: mysql:8.0
container_name: mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql
- ./init-scripts:/docker-entrypoint-initdb.d
ports:
- "127.0.0.1:3306:3306"
command: >
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_unicode_ci
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"]
interval: 10s
timeout: 5s
retries: 5
volumes:
mysql_data:
```
## MongoDB Configuration
```yaml
services:
mongodb:
image: mongo:7
container_name: mongodb
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
MONGO_INITDB_DATABASE: ${MONGO_DB}
volumes:
- mongo_data:/data/db
- mongo_config:/data/configdb
ports:
- "127.0.0.1:27017:27017"
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
volumes:
mongo_data:
mongo_config:
```
## Redis Configuration
```yaml
services:
redis:
image: redis:7-alpine
container_name: redis
restart: unless-stopped
command: >
redis-server
--appendonly yes
--maxmemory 256mb
--maxmemory-policy allkeys-lru
--requirepass ${REDIS_PASSWORD}
volumes:
- redis_data:/data
ports:
- "127.0.0.1:6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
interval: 10s
timeout: 5s
retries: 5
volumes:
redis_data:
```
## Connection Strings
### PostgreSQL
```
DATABASE_URL=postgresql://user:password@db:5432/dbname
```
### MySQL
```
DATABASE_URL=mysql://user:password@db:3306/dbname
```
### MongoDB
```
MONGO_URI=mongodb://user:password@mongodb:27017/dbname?authSource=admin
```
### Redis
```
REDIS_URL=redis://:password@redis:6379
```
## Backup Commands
```bash
# PostgreSQL
docker compose exec -T db pg_dumpall -c -U appuser > backup.sql
# MySQL
docker compose exec -T db mysqldump -u root -p"$PASS" --all-databases > backup.sql
# MongoDB
docker compose exec -T db mongodump --archive --gzip > backup.gz
# Redis (if persistence enabled)
docker compose exec redis redis-cli -a "$PASS" BGSAVE
```
## Restore Commands
```bash
# PostgreSQL
docker compose exec -T db psql -U appuser -d appdb < backup.sql
# MySQL
docker compose exec -T db mysql -u root -p"$PASS" < backup.sql
# MongoDB
docker compose exec -T db mongorestore --archive --gzip < backup.gz
```
## Best Practices
1. **Always use named volumes** for data persistence
2. **Bind to localhost only** (127.0.0.1) unless external access needed
3. **Use internal networks** to isolate database traffic
4. **Implement health checks** for dependency management
5. **Store credentials in .env** or Docker secrets
6. **Use initialization scripts** for schema setup
7. **Regular backups** before any risky operationsRelated Skills
Database Sync
Automate database synchronization, replication, migration, and cross-platform data integration
database-skill
Design and manage relational databases including table creation, migrations, and schema design. Use for database modeling and maintenance.
database-architect
Database design and optimization specialist. Schema design, query optimization, indexing strategies, data modeling, and migration planning for relational and NoSQL databases.
arch-database
DB architecture: relational vs document vs graph vs vector, schema design, indexing, replication, sharding
acsets-algebraic-databases
ACSets (Attributed C-Sets): Algebraic databases as in-memory data structures. Category-theoretic formalism for relational databases generalizing graphs and data frames.
vercel-kv-database-rules
Defines how to interact with Vercel's KV database for storing and retrieving session and application data.
Validate with Database
Connect to live PostgreSQL database to validate schema assumptions, compare pg_dump vs pgschema output, and query system catalogs interactively
sqlmap-database-pentesting
This skill should be used when the user asks to "automate SQL injection testing," "enumerate database structure," "extract database credentials using sqlmap," "dump tables and columns...
relational-database-mcp-cloudbase
This is the required documentation for agents operating on the CloudBase Relational Database. It lists the only four supported tools for running SQL and managing security rules. Read the full content to understand why you must NOT use standard Application SDKs and how to safely execute INSERT, UPDATE, or DELETE operations without corrupting production data.
railway-database
Add official Railway database services (Postgres, Redis, MySQL, MongoDB). Use when user wants to add a database, says "add postgres", "add redis", "add database", "connect to database", or "wire up the database". For other templates (Ghost, Strapi, n8n), use the railway-templates skill.
prisma-database-setup
Guides for configuring Prisma with different database providers (PostgreSQL, MySQL, SQLite, MongoDB, etc.). Use when setting up a new project, changing databases, or troubleshooting connection issues. Triggers on "configure postgres", "connect to mysql", "setup mongodb", "sqlite setup".
postgresql-docker
PostgreSQL in containers - Docker, Kubernetes, production configs