An open API service indexing awesome lists of open source software.

https://github.com/nithink-142/express-postgres-api


https://github.com/nithink-142/express-postgres-api

docker docker-compose express postgresql

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

          

# Express PostgreSQL API

## Setup PostgreSQL using Docker

### Prerequisites

- Download and install [Docker Desktop](https://www.docker.com/products/docker-desktop/).
- Install the pgAdmin extension within Docker.

### Steps

#### Pull the PostgreSQL Image

```bash
docker pull postgres
```

#### Run the PostgreSQL Container

```bash
docker run --name postgres-db -e POSTGRES_PASSWORD=8080 -p 5432:5432 -d postgres
```

**Note:** Port mapping is dynamic in this setup to avoid errors that occurred when specifying a static port.

#### Connect to pgAdmin

- **Host Name/Address:** `host.docker.internal`
- **Port:** Dynamic (it changes each time the container runs).

#### Connect to the Container

```bash
docker exec -it postgres-db psql -U postgres
```

## Useful Docker Commands

### View All Running Containers

```bash
docker ps
```

### Inspect Container Details

```bash
docker inspect
```

### Start/Stop a Container

- Start:
```bash
docker start postgres-db
```
- Stop:
```bash
docker stop postgres-db
```

### If Port Not Available error

- Start:
```bash
net stop winnat
```
- Stop:
```bash
net start winnat
```