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 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号