I have a docker compose file as below. One of the service starts a postgresql server.
version: "3.7"
services:
postgresql:
image: "postgres:13-alpine"
restart: always
volumes:
- type: bind
source: ./DO_NOT_DELETE_postgres_data
target: /var/lib/postgresql/data
environment:
POSTGRES_DB: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: abc123
PGDATA: "/var/lib/postgresql/data/pgdata"
networks:
- postgresql_network
otherservice:
.... (there are few other services also here)
networks:
postgresql_network:
driver: bridge
Now I try to start the docker compose
docker-compose up -d
Now after this I have do some things with the postgresql database from another service otherservice
eg:
docker-compose exec otherservice psql -h postgresql -U postgres -p abc123
How to check the postgresql service is up