运行容器
Ref: https://betterprogramming.pub/connect-from-local-machine-to-postgresql-docker-container-f785f00461a7
docker run -d -p 5432:5432 --name my-postgres -e POSTGRES_PASSWORD=root postgres
# 进入容器 inside the container
docker exec -it my-postgres bash
# 连接数据库
psql -U postgres
# 连接远程数据库
psql -h localhost -p 5432 -U postgres -W
备份数据库
Ref: https://stackoverflow.com/a/29913462/8945448
# backup SQL
docker exec -t <container_id> pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
# restore SQL
cat <your_dump>.sql | docker exec -i <container_id> psql -U postgres