This project streamlines the configuration of PostgreSQL and pgAdmin in Docker containers, facilitating database management via a web interface. Leveraging Docker and docker-compose, it establishes isolated environments for the database server (PostgreSQL) and management interface (pgAdmin), enhancing reproducibility and portability. This approach is suitable for development, testing, and production, offering a simple way to initiate database services.
To get your local environment set up with this project, follow these instructions. The process involves installing necessary software, cloning the repository, and configuring the environment.
Before you begin, you'll need to have Docker installed on your machine. Docker will manage the creation and running of the containers for PostgreSQL and pgAdmin.
Additionally, you'll need docker-compose to orchestrate the containers based on the docker-compose.yml file provided in this project.
- Docker: Follow the installation guide for your operating system on the Docker website.
- Docker Compose: Usually included with Docker Desktop for Windows and Mac. For Linux, follow the installation instructions on the Docker Compose website.
-
Environment Variables: Before starting, you'll need to create an
.env
file in the/environment
directory. This file should contain the necessary environment variables:POSTGRES_DB=your_db_name POSTGRES_USER=your_username POSTGRES_PASSWORD=your_password PGADMIN_DEFAULT_EMAIL=your_email PGADMIN_DEFAULT_PASSWORD=your_pgadmin_password
Replace the placeholders with your actual values.
-
Clone the Repository: Clone this project's repository to your local machine.
-
Launch the Services: Navigate to the directory containing the
docker-compose.yml
file and launch the services:docker-compose up -d
This command will download the required Docker images (if not already present), create the containers, and start the PostgreSQL and pgAdmin services.
-
Access pgAdmin: Once the containers are running, you can access pgAdmin by navigating to
https://localhost:5050
in your web browser. Log in using thePGADMIN_DEFAULT_EMAIL
andPGADMIN_DEFAULT_PASSWORD
you set in your.env
file. -
Connect to PostgreSQL: Within pgAdmin, create a new server connection to PostgreSQL. Use
postgres
as the host name (the service name defined indocker-compose.yml
), and enter thePOSTGRES_USER
andPOSTGRES_PASSWORD
from your.env
file.