# How to Set Up the Intermediate Bootcamp Database Environment with Docker

> Easily set up your intermediate bootcamp database environment with Docker. Clone the repo, copy env file, and run make up for PostgreSQL and PGAdmin.

- Repository: [DataExpert.io/data-engineer-handbook](https://github.com/DataExpert-io/data-engineer-handbook)
- Tags: how-to-guide
- Published: 2026-08-06

---

**Clone the DataExpert-io/data-engineer-handbook repository, copy `example.env` to `.env`, and run `make up` or `docker compose up -d` to start PostgreSQL and PGAdmin containers with pre-loaded sample data.**

The DataExpert-io/data-engineer-handbook intermediate bootcamp provides a containerized database environment for hands-on data modeling labs. This guide walks through setting up the **intermediate bootcamp database environment with Docker** using the official Docker Compose configuration from the repository.

## Architecture Overview

The bootcamp uses **Docker Compose** to orchestrate two services defined in [`docker-compose.yml`](https://github.com/DataExpert-io/data-engineer-handbook/blob/main/docker-compose.yml):

- **PostgreSQL 14** (`postgres:14`) – Stores the sample schema and data for dimensional modeling exercises
- **PGAdmin 4** (`dpage/pgadmin4`) – Web-based administration interface for querying and exploring the database

Key implementation details from [`intermediate-bootcamp/materials/1-dimensional-data-modeling/docker-compose.yml`](https://github.com/DataExpert-io/data-engineer-handbook/blob/main/intermediate-bootcamp/materials/1-dimensional-data-modeling/docker-compose.yml):

- Environment variables load from an `.env` file (based on `example.env`)
- The repository root mounts at `/bootcamp/` inside containers
- A `data.dump` file auto-imports into PostgreSQL on first startup via `/docker-entrypoint-initdb.d/`
- Named volumes (`postgres-data`, `pgadmin-data`) persist state across restarts

## Prerequisites

Before starting, ensure you have:

- Docker Engine 20.10+ and Docker Compose v2+
- Git for cloning the repository
- Approximately 2 GB free disk space for images and data

## Step-by-Step Setup

### 1. Clone the Repository

```bash
git clone https://github.com/DataExpert-io/data-engineer-handbook.git
cd data-engineer-handbook/intermediate-bootcamp/materials/1-dimensional-data-modeling

```

### 2. Configure Environment Variables

The `example.env` file in this directory contains default credentials. Copy it to `.env`:

```bash
cp example.env .env

```

Edit `.env` if you need custom ports or credentials. The defaults use:
- PostgreSQL user/password: `postgres` / `postgres`
- PGAdmin email/password: `postgres@postgres.com` / `postgres`

### 3. Start the Services

**macOS/Linux (recommended):**

```bash
make up

```

**All platforms:**

```bash
docker compose up -d

```

Both commands start containers in detached mode. The `Makefile` simply wraps Docker Compose with convenient targets.

### 4. Verify Container Status

```bash
docker ps -a

```

Expected output shows two running containers:
- `my-postgres-container` (PostgreSQL)
- `pgadmin` (PGAdmin web UI)

### 5. Access PGAdmin and Connect to PostgreSQL

1. Open `http://localhost:5050` in your browser
2. Log in with credentials from `.env` (default: `postgres@postgres.com` / `postgres`)
3. Add a new server with these settings:
   - **Name:** Any identifier (e.g., "Bootcamp DB")
   - **Host:** `my-postgres-container`
   - **Port:** `5432`
   - **Database:** `postgres`
   - **Username:** `postgres`
   - **Password:** `postgres`

The hostname `my-postgres-container` resolves because Docker Compose places both services on the same internal network.

### 6. Stop and Clean Up

| Command | Effect |
|---------|--------|
| `docker compose stop` | Pauses containers (preserves data) |
| `docker compose down` | Removes containers (preserves volumes) |
| `docker compose down -v` | Removes containers **and** volumes (erases all data) |
| `make restart` | Recreates PostgreSQL container (reloads `data.dump`) |

## How the Auto-Import Works

The `data.dump` file mounts to `/docker-entrypoint-initdb.d/` inside the PostgreSQL container. PostgreSQL's official image executes any `.sql`, `.sql.gz`, or `.dump` files in this directory on first initialization. This pattern, defined in the [`docker-compose.yml`](https://github.com/DataExpert-io/data-engineer-handbook/blob/main/docker-compose.yml), ensures every new container starts with identical sample data for the dimensional modeling labs.

## Makefile Convenience Commands

The `Makefile` provides shortcuts for common operations:

```bash
make up       # Start services

make stop     # Stop services

make restart  # Recreate PostgreSQL (useful after .env changes)

make logs     # Stream container logs

make ip       # Show PostgreSQL container IP address

make inspect  # Display detailed container configuration

```

## Troubleshooting Common Issues

**Port conflicts:** If port 5432 or 5050 is in use, modify `POSTGRES_PORT` or `PGADMIN_PORT` in `.env` before starting.

**Permission denied on Windows:** Ensure Docker Desktop is running in Linux container mode. The `data.dump` import requires Unix line endings—use Git's autocrlf setting or WSL2.

**PGAdmin cannot connect:** Verify the server host is `my-postgres-container` (not `localhost`). The containers communicate on Docker's internal network, not your host network.

## Summary

- The intermediate bootcamp database environment with Docker requires no local PostgreSQL installation
- Copy `example.env` to `.env` and run `make up` or `docker compose up -d` to start
- PostgreSQL 14 and PGAdmin 4 run in linked containers with persistent volumes
- `data.dump` auto-imports sample data on first container start via `/docker-entrypoint-initdb.d/`
- Use `make restart` to reset to clean state with fresh sample data

## Frequently Asked Questions

### What credentials should I use for PGAdmin?

Use the email and password defined in your `.env` file. The defaults from `example.env` are `postgres@postgres.com` for the email and `postgres` for the password. These are separate from the PostgreSQL database credentials.

### Why can't I connect to PostgreSQL from PGAdmin using localhost?

The containers run on an isolated Docker network. From PGAdmin's perspective, PostgreSQL is at hostname `my-postgres-container`, not `localhost`. Enter `my-postgres-container` as the host when registering the server in PGAdmin.

### How do I reset the database to its original state?

Run `make restart` or execute `docker compose down && docker compose up -d`. The `restart` target specifically recreates the PostgreSQL container, triggering the `data.dump` import fresh. To completely erase all data including volumes, use `docker compose down -v`.

### Where is the actual data stored?

PostgreSQL data persists in a Docker named volume (`postgres-data`) mapped to `/var/lib/postgresql/data` in the container. PGAdmin settings persist in `pgadmin-data`. These survive `docker compose stop` and `docker compose down` unless you explicitly remove volumes with `docker compose down -v`.