It includes a complete PostgreSQL environment with pgAdmin using Docker Compose for development and learning.
The complete presentation is available in PDF format: PostgreSQL in a nutshell
- Docker
- Docker Compose
Before running Docker Compose, you need to execute the setup script to create the necessary directories and configuration files.
# Give execution permission to the script
chmod +x setup.sh
# Run the setup script
./setup.sh# Run the setup script (as administrator if necessary)
setup.batAfter running the setup script, start the containers:
# Start the containers
docker-compose up -d
# Or to see logs in real time
docker-compose up-
PostgreSQL:
localhost:5432- User:
postgres - Password:
postgres - Database:
postgres
- User:
-
pgAdmin: http://localhost:8088
- Email:
admin@admin.com - Password:
postgres
- Email:
# Stop the containers
docker-compose down
# Stop and remove volumes (WARNING: deletes data)
docker-compose down -v
# View container logs
docker-compose logs
# View logs of a specific container
docker-compose logs postgres
docker-compose logs pgadmin
# Restart the containers
docker-compose restartTo completely remove all containers, volumes, and data created by this project:
# Give execution permission to the cleanup script
chmod +x cleanup.sh
# Run the cleanup script
./cleanup.sh# Run the cleanup script
cleanup.batpostgresql-nutshell/
├── docker-compose.yml # Container configuration
├── setup.sh # Setup script for Linux/macOS
├── setup.bat # Setup script for Windows
├── cleanup.sh # Cleanup script for Linux/macOS
├── cleanup.bat # Cleanup script for Windows
├── postgres/
│ ├── data/ # PostgreSQL data (created automatically)
│ ├── conf/ # PostgreSQL configurations (created automatically)
│ ├── servers.json # pgAdmin server configuration (created by setup)
│ └── pgpass # pgAdmin password file (created by setup)
└── README.md
The .sh scripts need execution permission:
# Give execution permission to setup script
chmod +x setup.sh
# Give execution permission to cleanup script
chmod +x cleanup.sh
# Check permissions
ls -la setup.sh cleanup.shThe .bat files usually don't need special permissions, but may need to be run as administrator depending on the system configuration.
To customize the configurations, edit the docker-compose.yml file:
- Change service ports
- Modify passwords and users
- Add environment variables
- Configure additional volumes
- PostgreSQL data is persisted in the
postgres/data/directory - pgAdmin comes pre-configured with the PostgreSQL connection
- Containers are configured to restart automatically
- Always run the setup script before first use
If ports 5432 or 8088 are already in use, change them in docker-compose.yml:
ports:
- "5433:5432" # PostgreSQL on port 5433
- "8089:80" # pgAdmin on port 8089On Linux/macOS, make sure the user has permission to create directories and files in the project directory.
Check if Docker is running and if you executed the setup script before docker-compose up.