This repository provides a Docker-based sandbox environment for users to train with PostgreSQL without needing to install it on their system. The setup includes PostgreSQL and pgAdmin4 for database management.
Ensure you have the following installed on your system:
-
Clone the repository:
git clone https://github.com/sc00bid00/postgres-docker-sandbox.git cd postgres-docker-sandbox
-
Set up environment variables: Ensure the
.env
file contains the necessary environment variables. You can customize these values as needed. -
Create necessary directories and start the containers:
For Linux/MacOS:
chmod +x setme-up.sh ./setme-up.sh
For Windows:
setme-up.bat
This will create the required directories, set permissions, and start the Docker containers.
-
pgAdmin will be accessible at
http://localhost:5050
- Login using the credentials specified in the
.env
file:- Email:
[email protected]
- Password:
PGAPW
- Email:
- Login using the credentials specified in the
-
PostgreSQL will be running on the default port
5432
- Access it using the credentials specified in the
.env
file:- Database:
PGDB
- User:
PGME
- Password:
PGPW
- Database:
- Access it using the credentials specified in the
The .env
file contains all the necessary configuration variables:
# PGADMIN LOGIN DATA
PGADMIN_DEFAULT_EMAIL=[email protected]
PGADMIN_DEFAULT_PASSWORD=PGAPW
PGADMIN_LISTEN_PORT=80
# DATABASE
HOST='postgres'
PORT=5432
POSTGRES_DB=PGDB
POSTGRES_USER=PGME
POSTGRES_PASSWORD=PGPW
# CONF
DATE_FORMAT='d.m.Y'
DECIMAL_SEP=','
THOUSAND_SEP=''
CSV_DELIMITER=';'
Feel free to customize these values according to your preferences.
Here is the expected folder structure after setting up the sandbox:
postgres-docker-sandbox/
├── .env
├── docker-compose.yml
├── setme-up.sh
├── setme-up.bat
├── postgres_data/ # Directory for PostgreSQL data
├── pgadmin/ # Directory for pgAdmin data
└── README.md
- .env: Environment variables for the setup.
- docker-compose.yml: Docker Compose configuration file.
- setme-up.sh: Setup script for Linux/MacOS.
- setme-up.bat: Setup script for Windows.
- postgres_data/: Directory where PostgreSQL will store its data.
- pgadmin/: Directory where pgAdmin will store its data.
- README.md: This README file.
If you encounter any issues, follow these steps:
-
Check container logs:
docker compose logs
-
Restart the containers:
docker compose down docker compose up
-
Verify Docker and Docker Compose installation: Ensure you have the latest versions installed.
-
File and directory permissions: Ensure the directories
./postgres_data
and./pgadmin
have the correct permissions.
We welcome contributions! Please fork the repository and create a pull request with your changes. Ensure your code adheres to the existing style and passes all tests.
This project is licensed under the MIT License. See the LICENSE file for details.
Happy coding!