简体   繁体   English

在 Docker 中运行时,Firestore 模拟器无法启动

[英]Firestore Emulator fails to start when run inside Docker

I am running a docker image based on alpine that has nodejs and openjdk8 installed.我正在运行一个基于alpine nodejsopenjdk8安装了nodejsopenjdk8 After I successfully install firebase-tools via npm and I try to start the firestore emulator using this command:通过npm成功安装firebase-tools ,我尝试使用以下命令启动 firestore 模拟器:

firebase serve --only firestore

I get the following error:我收到以下错误:

    ⚠  firestore: Exception in thread "main"
    ⚠  firestore: java.io.IOException: Failed to bind

    ⚠  firestore:   at io.grpc.netty.NettyServer.start(NettyServer.java:256)
            at io.grpc.internal.ServerImpl.start(ServerImpl.java:167)
            at io.grpc.internal.ServerImpl.start(ServerImpl.java:81)
            at io.gapi.emulators.grpc.GrpcServer.start(GrpcServer.java:151)
            at com.google.cloud.datastore.emulator.firestore.CloudFirestore.main(CloudFirestore.java:69)
    Caused by: java.net.SocketException: Protocol family unavailable
            at sun.nio.ch.Net.bind0(Native Method)
            at sun.nio.ch.Net.bind(Net.java:433)
            at sun.nio.ch.Net.bind(Net.java:425)
            at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)

    ⚠  firestore:   at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:130)
            at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562)
            at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1358)
            at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501)
            at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486)
            at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:1019)
            at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:258)
            at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:366)
            at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)

    ⚠  firestore:   at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
            at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:474)
            at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
            at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
            at java.lang.Thread.run(Thread.java:748)

I tried setting the JAVA_OPTS as follows:我尝试设置JAVA_OPTS如下:

export JAVA_OPTS="-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv4Addresses=true"

But I still get a similar error:但我仍然收到类似的错误:

    ⚠  firestore: Exception in thread "main"
    ⚠  firestore: java.io.IOException: Failed to bind
            at io.grpc.netty.NettyServer.start(NettyServer.java:256)
            at io.grpc.internal.ServerImpl.start(ServerImpl.java:167)
            at io.grpc.internal.ServerImpl.start(ServerImpl.java:81)
            at io.gapi.emulators.grpc.GrpcServer.start(GrpcServer.java:151)
            at com.google.cloud.datastore.emulator.firestore.CloudFirestore.main(CloudFirestore.java:69)
    Caused by: java.net.SocketException: Protocol family unavailable
            at sun.nio.ch.Net.bind0(Native Method)
            at sun.nio.ch.Net.bind(Net.java:433)
            at sun.nio.ch.Net.bind(Net.java:425)
            at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
            at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:130)
            at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562)
            at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1358)
            at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501)
            at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486)
            at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:1019)
            at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:258)
            at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:366)
            at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
            at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
            at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:474)
            at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:909)
            at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
            at java.lang.Thread.run(Thread.java:748)

Has anyone seen this error and found a solution?有没有人看到这个错误并找到了解决方案?

解决方案很简单,但我必须承认没有多大意义,就是直接运行 JAR,而不是通过firebase工具启动它。

java -jar $HOME/.cache/firebase/emulators/cloud-firestore-emulator-v1.3.0.jar --host=127.0.0.1

Is it trying to bind to an IPV6 address ?它是否试图绑定到 IPV6 地址? To use with a custom port with IPV4 with google cloud SDK:使用带有谷歌云 SDK 的带有 IPV4 的自定义端口:

gcloud beta emulators firestore start --host-port=127.0.0.1:8772

Or else, try to enable IPV6 on you docker ?或者,尝试在您的 docker启用 IPV6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Docker-compose:如何知道容器中的jar完成运行并随后启动其他容器的时间 - Docker-compose: how to know when jar inside a container finish to run and later start other container mvn jetty:在docker内部运行时不反映更改 - mvn jetty:run not reflecting changes when run inside docker 由于APK文件无效,安装失败! (尝试运行模拟器时)在尝试导出时也失败 - Installation failed due to invalid APK file! (when attempting to run emulator) Also fails when attempting to export 在 docker 容器内运行时,HeapDumpOnOutOfMemoryError 不会转储堆 - HeapDumpOnOutOfMemoryError doesn't dump heap when run inside docker container 在模拟器中运行时,按钮消失 - Button dissapears when run in emulator 在 Docker 上运行“ProcessBuilder.start”失败 - Running "ProcessBuilder.start" on Docker fails Android Studio模拟器无法启动与内存限制相关的错误消息 - Android studio emulator fails to start with memory limit related error message 为什么我的 java docker 图像在笔记本电脑上创建成功,但上传到谷歌云运行时失败? - Why is my java docker image created successfully on laptop but when uploading to google cloud run it fails? 由于 docker 容器内的 proguard 混淆,构建失败 - Build fails with proguard obfuscation inside docker container docker 使用端口转发运行失败 - docker run with port-forward fails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM