duanlu8613 2019-05-05 09:06
浏览 1373

我试图在docker中部署gRPC(go)服务器并在本地端口中公开端口,但是端口绑定不起作用

I tried to deploy gRPC server and mongodb in docker. After that I trying to binding docker ports to my local ports. mongodb ports binding was working fine. But, gRPC server ports are not binding my local port

ports:
  - "50051:50051"

like this i tried in docker-compose.yml

docker-compose.yml

services:
  auth_server:
    container_name: auth_service
    build: .
    command: go run server.go
    volumes:
      - .:/go/src/auth_server
    working_dir: /go/src/auth_server
    ports:
      - "50051:50051"
    environment:
      PORT: 50051

In client gRPC file I used host and port like, 0.0.0.0:50051

conn, err := grpc.Dial("0.0.0.0:50051", grpc.WithInsecure())

but it was not working. I can't find any bug, so I assume I am doing something incorrectly.

  • 写回答

1条回答 默认 最新

  • dousi0144 2019-05-05 09:31
    关注

    You should use 127.0.0.1:50051 when connecting from a client on the host machine, or auth_server:50051 if you are connecting from docker-compose network.

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器