Docker compose database lab
Skill POWR-DATA/mtx-skills/skills/infra/docker-compose-database-lab
Reusable AI agent skills for application development, data, architecture, domain modelling and delivery workflows.
npx -y skills add POWR-DATA/mtx-skills --skill docker-compose-database-labAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Set up local Docker Compose database environments with correct volume mounts, configuration, and network access
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
6.7 KB, as published. Nobody here has run it
Docker Compose Database Lab
Purpose
Set up a local Docker Compose development environment for database work, avoiding common gotchas around volume mounts, environment file placement, and corporate network access. This skill ensures containers start reliably and persist data correctly.
When to use
- Initialising a new Docker Compose setup for local database development
- Debugging "container restarts immediately" or "data not persisting" issues
- Setting up database containers behind a corporate proxy or restricted network
- Migrating between PostgreSQL versions with breaking volume mount changes
Inputs expected
- Target database (PostgreSQL, MySQL, SQL Server, etc.) and version
- Corporate network constraints (proxy requirements, registry mirrors)
- Volume mount paths and desired data persistence model
- Environment configuration (
.envvariables, secrets)
Guiding principles
- Volume mounts are version-specific. PostgreSQL 18 uses
/var/lib/postgresqlas the container data path. Using the older/var/lib/postgresql/datamount with PG18 causes immediate restart loops with an "unused mount" error. - Compose reads
.envfrom the directory containingcompose.yaml, not from the repository root. Place.envandcompose.yamlin the same subdirectory; Compose silently ignores misplaced files. - Corporate networks often block direct Docker Hub access. Use Artifactory mirrors for Docker Hub images; Microsoft Container Registry (MCR) typically works without a mirror on the same networks.
- Named volumes survive container recreation; bind mounts do not. Use named volumes for persistent data; use bind mounts only for development code.
- Health checks prevent dependent services from starting before the database is ready. Always include a
healthcheckin the database service and reference it in dependent services'depends_on. - Escape runtime env vars in
CMD-SHELLhealthchecks. Use$$VAR_NAMEin Compose healthchecks so$is passed literally to the container shell; this prevents silent truncation when secrets contain$.
Process
- Identify the database image and version. Check the upstream image documentation (Docker Hub, vendor site) for the container's expected volume mount paths.
- Choose a volume strategy. Decide: named volume (persistent across compose restarts) or bind mount (synchronised with local filesystem). Use named volumes for databases; use bind mounts for code or configuration that developers edit.
- Create the directory structure. Place
compose.yamland.envin the same subdirectory (e.g.docker/orinfra/docker/). Do not place.envat the repository root. - Define services in
compose.yaml. Include explicit volume mounts with the correct container paths for the version in use. Add ahealthcheckto the database service. Reference the healthcheck in dependent services. - Populate
.envwith database credentials and configuration. Use strong, randomly generated values for development. Document which variables are required. - Test volume persistence. Start the service, create test data, stop the service, restart, and verify the data is still present. If the container restarts immediately, check the volume mount path against the image documentation.
- Handle major version mount changes. When moving to PostgreSQL 18 from older versions, update mounts to
/var/lib/postgresqland remove stale named volumes before restarting. - Configure network access if needed. If behind a corporate proxy, add
registry-mirrorsto Docker daemon config or useimage:URIs that point to Artifactory mirrors for Docker Hub images. - Validate shell-based healthchecks with special-character secrets. For SQL Server and other
CMD-SHELLchecks, reference variables as$$MSSQL_SA_PASSWORD(not${MSSQL_SA_PASSWORD}) so runtime expansion is correct.
Output format
A working compose.yaml and .env template with:
- Database service definition — image, version, volume mounts (correct for the version), environment variables, healthcheck
- Volume declaration (if using named volumes) — name and driver
- Network declaration (if needed) — custom network for service-to-service communication
- Dependent service examples (e.g., backup, load scripts) — showing how to reference the database healthcheck
- .env template — required variables, descriptions, example values (using placeholders like
<your-password>) - Troubleshooting checklist — volume path verification, .env placement verification, container restart diagnosis
Quality checklist
- Volume mount paths match the database image documentation for the specified version
-
.envandcompose.yamlare in the same directory - Database service includes a
healthcheckcommand appropriate for the database type - Dependent services reference
depends_on: db: condition: service_healthy - Named volumes are explicitly declared in the
volumes:section -
.envtemplate uses generic placeholders (<your-username>,<your-password>), not real credentials - Example demonstrated on the target version and tested for data persistence
-
CMD-SHELLhealthchecks use$$VARescaping for passwords that may include$
Avoid
- Placing
.envat the repository root — Compose will not find it. - Reusing volume mount paths from older PostgreSQL versions without checking current documentation — PostgreSQL 18 expects
/var/lib/postgresql. - Omitting healthchecks — dependent services will start before the database is ready.
- Using
${MSSQL_SA_PASSWORD}directly inside aCMD-SHELLhealthcheck — use$$MSSQL_SA_PASSWORDto avoid shell re-expansion bugs. - Using
POSTGRES_PASSWORDas an environment variable directly incompose.yaml— always read from.env. - Mixing named volumes and bind mounts for the same data (e.g., a named volume for data and a bind mount for backups in the same directory).
Example usage
I'm setting up a local PostgreSQL 18 and PostGIS environment for geospatial development. I have data that needs to persist across restarts, and I'm on a corporate network that blocks Docker Hub. Help me create a
compose.yamlthat mounts volumes correctly for PG18, uses a local Artifactory mirror, and includes a backup service that depends on the database being healthy.
Source: This skill is sourced from the Matrix Skills library. Learn more at the AI Agent Skills Library.