Start IBM Db2 Community Edition in Docker, create a schema, and practice Db2 SQL and the command line processor.
| Field | Detail |
|---|---|
| Repository | ibm-db2-lab |
| Primary language | Mixed / documentation |
| Topics | database, database-labs, devarent, docker, ibm-db2, lab, relational-database, sql |
| License | MIT |
| Branch | main |
| Maintainer | @devarent |
ibm-db2-lab is a hands-on repository focused on: Start IBM Db2 Community Edition in Docker, create a schema, and practice Db2 SQL and the command line processor.. Primary language: Mixed / documentation. Topics: database, database-labs, devarent, docker, ibm-db2, lab, relational-database, sql. The README below documents the project; use the table above for a quick overview.
🇮🇸 Iceland · 🇳🇿 New Zealand · 🇨🇭 Switzerland · 🇸🇮 Slovenia · 🇮🇪 Ireland · 🇦🇹 Austria · 🇵🇹 Portugal · 🇸🇬 Singapore · 🇫🇮 Finland
Start IBM Db2 Community Edition in Docker, create a schema, and practice Db2 SQL and the command line processor.
Start IBM Db2 Community Edition in Docker, create a schema, and practice Db2 SQL and the command line processor.
Db2 is a long-running enterprise relational database with strong SQL standards coverage. This lab runs Db2 Community Edition locally, shows the command line processor workflow, and gives you a schema plus queries that exercise identity columns, CTEs, and Db2-specific syntax.
docker compose up -d
docker compose logs -f db2 # wait for: Setup has completed
docker compose cp examples/01_schema.sql db2:/tmp/01_schema.sql
docker compose exec db2 su - db2inst1 -c 'db2 -tvf /tmp/01_schema.sql'
docker compose exec db2 su - db2inst1 -c 'db2 connect to LAB && db2 "SELECT current_server, current_time FROM sysibm.sysdummy1"'| Field | Value |
|---|---|
| Host | localhost |
| Port | 50000 |
| Database | LAB |
| User | db2inst1 |
| Password | db2inst1 |
| JDBC URL | jdbc:db2://localhost:50000/LAB |
| CLP | db2 connect to LAB |
| File | What it shows |
|---|---|
docker-compose.yml |
Engine, ports, and persistent volume. |
.github/workflows/compose-check.yml |
Validates the Compose file on every push. |
examples/01_schema.sql |
Db2 schema with identity columns, constraints, and a summary view. |
examples/02_queries.sql |
Seed data, a CTE, FETCH FIRST, and a window function. |
- Run
db2 -tvf examples/02_queries.sqland inspect the output oforder_summary. - Add a
productstable and aMERGEstatement that upserts prices. - Use
db2explnorEXPLAIN PLAN FORto inspect the access plan for the revenue query. - Create a tablespace and move an index into it (requires more Db2 administration than the default lab setup).
- The image is large (several GB) and needs roughly 4 GB of RAM. First start can take 5-10 minutes.
- Db2 Community Edition is free for development, but review IBM's license terms before production use.
- The container runs as privileged because Db2 needs kernel settings that the image manages itself.
- This image is published for linux/amd64. Apple Silicon users need emulation.
This lab publishes its ports on 127.0.0.1 only. To use it from another country, do not open the database port to the internet. Pick one:
- VPS + private tunnel: run the lab on a small Ubuntu VPS, keep the port closed, and connect through WireGuard or
ssh -L. - Managed service: use a managed free tier for this engine and point the same examples at its connection string.
- HTTP UI only: if the engine has a web UI, put it behind Caddy with TLS and basic auth.
The shared checklist, provider map, and commands are in REMOTE-ACCESS.md.
docker compose down -v-v also removes the named volume, so the next start is a clean slate.
Part of the database-labs collection: 26 database engines, one index.
MIT (c) 2026 Arya Fatthurahman. See LICENSE.
Full Tech Stack Wall
Connection names shown in the DBX sidebar - decorative reference badges.