Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup/Add PostgreSQL/pgAdmin Docker Compose #3

Merged
merged 3 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Directories of docker-compose-files
Putting these docker-compose-files makes it tirivial to share (easy configuring alternative to existing services) with the world.

## Docker Setups
List of Docker Compose setups.

- [`PostgreSQL / pgAdmin`](https://github.com/bhavik2936/docker-compose-files/blob/main/postgres-pgadmin) - Basic setup of PostgreSQL database with pgAdmin.

## Feedback
Suggestions/improvements are [welcomed](https://github.com/bhavik2936/docker-compose-files/issues)!
28 changes: 28 additions & 0 deletions postgres-pgadmin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Postgres-pgAdmin Docker Compose
It contains docker instances for both **PostgreSQL** & **pgAdmin** internally connected via bridge network.

### PostgreSQL
Postgres, the database server itself can be accessed on host machine (localhost) on port _5432_.

#### Description
Below configuration are already set by default via `pgCreds.env` file and can be modified by overriding the same.

| Config | Value | Comment |
| -------- | ----- | -------------------------------- |
| Port | 5432 | Exposed at localhost (127.0.0.1) |
| Username | root | |
| Password | root | |

### pgAdmin
pgAdmin is integrated to graphically visualize the postgres database.
It can be accessed on host machine (localhost) web browser at http://localhost:8088.

#### Configuration
Below configuration are already set by default via `pgAdminCreds.env` file and can be modified by overriding the same.

| Config | Value | Comment |
| -------- | ------------------ | ----------------------------------------------------------------- |
| Port | 8088 | Exposed at localhost (127.0.0.1) |
| Username | admin@postgres.com | |
| Password | pgadmin | |
| Host | postgres | To connect docker instance server of postgres database in pgAdmin |
44 changes: 44 additions & 0 deletions postgres-pgadmin/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Version of docker-compose file is no longer required
version: '3.3'

services:

postgres:
image: postgres
container_name: postgres
restart: unless-stopped
ports:
- 5432:5432
env_file:
- pgCreds.env
networks:
- pg-network
volumes:
- pg-data:/var/lib/postgresql/data

pgadmin:
image: dpage/pgadmin4
container_name: pgadmin
depends_on:
- postgres
restart: unless-stopped
env_file:
- pgAdminCreds.env
ports:
- 8088:80
networks:
- pg-network
volumes:
- pgadmin-data:/var/lib/pgadmin

# Bridge type of network connecting to both (postgres, pgadmin) containers.
# As recommended by docker (https://docs.docker.com/network/bridge)
networks:
pg-network:
name: pg-network
driver: bridge

# Named volumes for persisting necessary containers' data across restart.
volumes:
pg-data:
pgadmin-data:
2 changes: 2 additions & 0 deletions postgres-pgadmin/pgAdminCreds.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PGADMIN_DEFAULT_EMAIL=admin@postgres.com
PGADMIN_DEFAULT_PASSWORD=pgadmin
2 changes: 2 additions & 0 deletions postgres-pgadmin/pgCreds.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
POSTGRES_USER=root
POSTGRES_PASSWORD=root