我目前正在使用Prisma和Postgres数据库开发应用程序,但我无法将我的数据库连接到Navicat。我是 docker 的初学者,并不完全了解服务的工作原理。我目前的docker-compose.yml
是
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.8
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
# managementApiSecret: my-secret
databases:
default:
connector: postgres
host: postgres
port: 5432
user: prisma
password: prisma
migrations: true
postgres:
image: postgres
restart: always
environment:
POSTGRES_USER: prisma
POSTGRES_PASSWORD: prisma
volumes:
- postgres:/var/lib/postgresql/data
volumes:
postgres:
我在 Navicat 上尝试的是这个,在我看来是正确的,但似乎没有。
谢谢你的帮助!
您需要使用postgres
容器的ports
属性使用端口映射:
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.8
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
# managementApiSecret: my-secret
databases:
default:
connector: postgres
host: postgres
port: 5432
user: prisma
password: prisma
migrations: true
postgres:
image: postgres
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_USER: prisma
POSTGRES_PASSWORD: prisma
volumes:
- postgres:/var/lib/postgresql/data
volumes:
postgres:
然后,您应该能够使用Postgres客户端(如Navicat(连接到localhost:5432
。