Adding postgreSQL / pgAdmin example
Signed-off-by: Leon Stoldt <tech@leon-stoldt.de>
This commit is contained in:
parent
acf94458dc
commit
1fd4ba878d
@ -35,6 +35,7 @@ application with an Nginx proxy and a MySQL database.
|
|||||||
- [`NGINX / Go`](https://github.com/docker/awesome-compose/tree/master/nginx-golang) - Sample Nginx proxy with a Go backend.
|
- [`NGINX / Go`](https://github.com/docker/awesome-compose/tree/master/nginx-golang) - Sample Nginx proxy with a Go backend.
|
||||||
- [`NGINX / WSGI / Flask`](https://github.com/docker/awesome-compose/tree/master/nginx-wsgi-flask) - Sample Nginx reverse proxy with a Flask backend using WSGI.
|
- [`NGINX / WSGI / Flask`](https://github.com/docker/awesome-compose/tree/master/nginx-wsgi-flask) - Sample Nginx reverse proxy with a Flask backend using WSGI.
|
||||||
- [`Pi-hole / cloudflared`](https://github.com/docker/awesome-compose/tree/master/pihole-cloudflared-DoH) - Sample Pi-hole setup with use of DoH cloudflared service
|
- [`Pi-hole / cloudflared`](https://github.com/docker/awesome-compose/tree/master/pihole-cloudflared-DoH) - Sample Pi-hole setup with use of DoH cloudflared service
|
||||||
|
- [`PostgreSQL / pgAdmin`](https://github.com/docker/awesome-compose/tree/master/postgresql-pgadmin) - Sample setup for postgreSQL database with pgAdmin web interface
|
||||||
- [`React / Spring / MySQL`](https://github.com/docker/awesome-compose/tree/master/react-java-mysql) - Sample React
|
- [`React / Spring / MySQL`](https://github.com/docker/awesome-compose/tree/master/react-java-mysql) - Sample React
|
||||||
application with a Spring backend and a MySQL database.
|
application with a Spring backend and a MySQL database.
|
||||||
- [`React / Express / MySQL`](https://github.com/docker/awesome-compose/tree/master/react-express-mysql) - Sample React
|
- [`React / Express / MySQL`](https://github.com/docker/awesome-compose/tree/master/react-express-mysql) - Sample React
|
||||||
|
5
postgresql-pgadmin/.env
Normal file
5
postgresql-pgadmin/.env
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
POSTGRES_USER=yourUser
|
||||||
|
POSTGRES_PW=changeit
|
||||||
|
POSTGRES_DB=postgres
|
||||||
|
PGADMIN_MAIL=your@email.com
|
||||||
|
PGADMIN_PW=changeit
|
68
postgresql-pgadmin/README.md
Normal file
68
postgresql-pgadmin/README.md
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
## PostgreSQL and pgAdmin
|
||||||
|
This example provides a base setup for using [PostgreSQL](https://www.postgresql.org/) and [pgAdmin](https://www.pgadmin.org/).
|
||||||
|
More details on how to customize the installation and the compose file can be found [here (PostgreSQL)](https://hub.docker.com/_/postgres) and [here (pgAdmin)](https://www.pgadmin.org/docs/pgadmin4/latest/container_deployment.html).
|
||||||
|
|
||||||
|
Project structure:
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── .env
|
||||||
|
├── docker-compose.yaml
|
||||||
|
└── README.md
|
||||||
|
```
|
||||||
|
|
||||||
|
[_docker-compose.yaml_](docker-compose.yaml)
|
||||||
|
``` yaml
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:latest
|
||||||
|
...
|
||||||
|
pgadmin:
|
||||||
|
image: dpage/pgadmin4:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
### .env
|
||||||
|
Before deploying this setup, you need to configure the following values in the [.env](.env) file.
|
||||||
|
- POSTGRES_USER
|
||||||
|
- POSTGRES_PW
|
||||||
|
- POSTGRES_DB (can be default value)
|
||||||
|
- PGADMIN_MAIL
|
||||||
|
- PGADMIN_PW
|
||||||
|
|
||||||
|
## Deploy with docker-compose
|
||||||
|
When deploying this setup, the pgAdmin web interface will be available at port 5050 (e.g. http://localhost:5050).
|
||||||
|
|
||||||
|
``` shell
|
||||||
|
$ docker-compose up
|
||||||
|
Starting postgres ... done
|
||||||
|
Starting pgadmin ... done
|
||||||
|
```
|
||||||
|
|
||||||
|
## Add postgres database to pgAdmin
|
||||||
|
After logging in with your credentials of the .env file, you can add your database to pgAdmin.
|
||||||
|
1. Right-click "Servers" in the top-left corner and select "Create" -> "Server..."
|
||||||
|
2. Name your connection
|
||||||
|
3. Change to the "Connection" tab and add the connection details:
|
||||||
|
- Hostname: "postgres" (this would normally be your IP address of the postgres database - however, docker can resolve this container ip by its name)
|
||||||
|
- Port: "5432"
|
||||||
|
- Maintenance Database: $POSTGRES_DB (see .env)
|
||||||
|
- Username: $POSTGRES_USER (see .env)
|
||||||
|
- Password: $POSTGRES_PW (see .env)
|
||||||
|
|
||||||
|
## Expected result
|
||||||
|
|
||||||
|
Check containers are running:
|
||||||
|
```
|
||||||
|
$ docker ps
|
||||||
|
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||||
|
849c5f48f784 postgres:latest "docker-entrypoint.s…" 9 minutes ago Up 9 minutes 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp postgres
|
||||||
|
d3cde3b455ee dpage/pgadmin4:latest "/entrypoint.sh" 9 minutes ago Up 9 minutes 443/tcp, 0.0.0.0:5050->80/tcp, :::5050->80/tcp pgadmin
|
||||||
|
```
|
||||||
|
|
||||||
|
Stop the containers with
|
||||||
|
``` shell
|
||||||
|
$ docker-compose down
|
||||||
|
# To delete all data run:
|
||||||
|
$ docker-compose down -v
|
||||||
|
```
|
22
postgresql-pgadmin/docker-compose.yaml
Normal file
22
postgresql-pgadmin/docker-compose.yaml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
version: '3.7'
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
container_name: postgres
|
||||||
|
image: postgres:latest
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=${POSTGRES_USER}
|
||||||
|
- POSTGRES_PASSWORD=${POSTGRES_PW}
|
||||||
|
- POSTGRES_DB=${POSTGRES_DB} #optional (specify default database instead of $POSTGRES_USER)
|
||||||
|
ports:
|
||||||
|
- "5432:5432"
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
pgadmin:
|
||||||
|
container_name: pgadmin
|
||||||
|
image: dpage/pgadmin4:latest
|
||||||
|
environment:
|
||||||
|
- PGADMIN_DEFAULT_EMAIL=${PGADMIN_MAIL}
|
||||||
|
- PGADMIN_DEFAULT_PASSWORD=${PGADMIN_PW}
|
||||||
|
ports:
|
||||||
|
- "5050:80"
|
||||||
|
restart: always
|
Loading…
Reference in New Issue
Block a user