docs: update docs of README.mds.

summary: update command docker compose to docker-compose.
This commit is contained in:
Mark
2023-01-05 22:29:01 +08:00
parent 20e3e4c434
commit 4b0c67e2aa
40 changed files with 518 additions and 332 deletions

View File

@@ -1,8 +1,10 @@
## 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
@@ -11,7 +13,8 @@ Project structure:
```
[_compose.yaml_](compose.yaml)
``` yaml
```yaml
services:
postgres:
image: postgres:latest
@@ -23,7 +26,9 @@ services:
## 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)
@@ -31,28 +36,33 @@ Before deploying this setup, you need to configure the following values in the [
- 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
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.
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
@@ -61,8 +71,9 @@ d3cde3b455ee dpage/pgadmin4:latest "/entrypoint.sh" 9 minute
```
Stop the containers with
``` shell
$ docker compose down
```shell
$ docker-compose down
# To delete all data run:
$ docker compose down -v
$ docker-compose down -v
```