https://github.com/arunkumar201/sql-playground
sql-playground
https://github.com/arunkumar201/sql-playground
docker docker-compose postgresql sql
Last synced: 3 months ago
JSON representation
sql-playground
- Host: GitHub
- URL: https://github.com/arunkumar201/sql-playground
- Owner: arunkumar201
- Created: 2024-04-07T16:00:22.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-10-25T07:49:14.000Z (5 months ago)
- Last Synced: 2025-10-25T09:23:19.040Z (5 months ago)
- Topics: docker, docker-compose, postgresql, sql
- Language: Dockerfile
- Homepage:
- Size: 34.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PostgreSQL Docker Setup
Dockerfile for setting up a PostgreSQL database locally using Docker.
## Prerequisites
- Docker installed on your machine.
## Getting Started
Follow these instructions to build and run the PostgreSQL Docker container.
### Build the Docker Image
1. Clone this repository to your local machine.
2. Navigate to the directory containing the Dockerfile.
3. Build the Docker image using the following command:
```bash
docker build -t my-postgres-image .
```
### Run the Docker Container
1. Run a container from the image with the following command:
```bash
docker run --name my-postgres-container -d -p 5432:5432 my-postgres-image
```
- `--name my-postgres-container`: Names the running container.
- `-d`: Runs the container in detached mode.
- `-p 5432:5432`: Maps the container's port 5432 to the host's port 5432.
### Environment Variables
The following environment variables are set in the Dockerfile:
- `POSTGRES_USER`: The username for the PostgreSQL database (default: `root`).
- `POSTGRES_PASSWORD`: The password for the PostgreSQL database (default: `password`).
- `POSTGRES_DB`: The default database to be created (default: `learning_sql`).
### Accessing PostgreSQL
You can connect to the PostgreSQL database using any PostgreSQL client with the following credentials:
- **Host**: `localhost`
- **Port**: `5432`
- **Username**: `root`
- **Password**: `password`
- **Database**: `learning_sql`
### Stopping the Container
To stop the running container, use the following command:
```bash
docker stop my-postgres-container
```
### Removing the Container
To remove the container, use the following command:
```bash
docker rm my-postgres-container
```