Prisma-docker 无法连接到服务器
Posted
技术标签:
【中文标题】Prisma-docker 无法连接到服务器【英文标题】:Prisma-docker could not connect to server 【发布时间】:2019-12-23 17:45:10 【问题描述】:我尝试了这个answer,但我得到了一个带有 ls 的空列表
问题:我无法将 prisma 连接到 atlas 免费层集群
在使用 graphql-yoga 和 apollo-server 设置 graphql 服务器时,这种情况已经发生了两次,所以这次我在没有服务器但只有 prisma 的情况下尝试了它。
我的步骤:
在 atlas 中我使用了加载示例数据
prisma init
我选择连接到现有的 mongodb 并提供了连接字符串(生成的文件在问题的末尾)
docker-compose up -d
容器已创建(此处没有错误)
prisma deploy
我收到了这条消息:
无法连接到http://localhost:4466 的服务器。请检查您的服务器是否正在运行。
所以我去拿了容器日志
docker logs <id>
Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at com.prisma.local.PrismaLocalMain$.main(PrismaLocalMain.scala:8)
at com.prisma.local.PrismaLocalMain.main(PrismaLocalMain.scala) Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: com.prisma.config.InvalidConfiguration: Expected host to be non-empty
at scala.sys.package$.error(package.scala:26)
at com.prisma.config.ConfigLoader$.load(ConfigLoader.scala:40)
at com.prisma.local.PrismaLocalDependencies.<init>(PrismaLocalDependencies.scala:48)
at com.prisma.local.PrismaLocalMain$.delayedEndpoint$com$prisma$local$PrismaLocalMain$1(PrismaLocalMain.scala:13)
at com.prisma.local.PrismaLocalMain$delayedInit$body.apply(PrismaLocalMain.scala:8)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:388)
at scala.App.main(App.scala:76)
docker-compose.yml
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.34
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: mongo
schema: sample_weatherdata
uri: >-
mongodb+srv://admin:admin@demonic-one-sdk7x.mongodb.net/test?retryWrites=true&w=majority
prisma.yml
endpoint: http://localhost:4466
datamodel: datamodel.prisma
databaseType: document
generate:
- generator: javascript-client
output: ./generated/prisma-client/
【问题讨论】:
【参考方案1】:这解决了您遇到的错误。我无法连接到您的 MongoDB 实例进行完整测试,但至少它解决了您的问题。
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.34
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: mongo
host: demonic-one-sdk7x.mongodb.net
user: admin
password: admin
uri: >-
mongodb+srv://admin:admin@demonic-one-sdk7x.mongodb.net/test?retryWrites=true&w=majority
【讨论】:
这看起来不错。但我无法让它在我的本地主机上运行。我没有访问限制。知道我的默认连接器有什么问题吗?default: connector: mongo host: localhost:27017 uri: >- mongodb+srv://@localhost:27017/dbname?retryWrites=true&w=majority
您是否收到错误消息?你想在哪里使用这个连接器?
我在这个问题上开了一个问题。请在这里查看更多详细信息。谢谢你。 github.com/prisma/prisma/issues/4922以上是关于Prisma-docker 无法连接到服务器的主要内容,如果未能解决你的问题,请参考以下文章
无法使用php连接错误连接到mysql:无法连接到'localhost'(10061)上的MySQL服务器[重复]
Django docker 容器无法连接到 mysql 容器,出现错误“无法连接到 'db' (111) 上的 MySQL 服务器”)