grpcui icon indicating copy to clipboard operation
grpcui copied to clipboard

How to run Docker?

Open ZedZipDev opened this issue 4 years ago • 3 comments
trafficstars

  1. I run my ASP.NET gRPC server with ports http://localhost:54320; https://localhost:54321

1.1. Then I run the grpcui.exe PS D:_Docker> grpcui localhost:54321 gRPC Web UI available at http://127.0.0.1:56677/ PS D:_Docker> and it works fine: I see my browser page.

  1. Now I want to use docker: 2.1. docker pull fullstorydev/grpcui 2.2 docker run -it --rm -p 0.0.0.0:8180:8080 fullstorydev/grpcui:latest localhost:54321 Failed to dial target host "localhost:54321": dial tcp 127.0.0.1:54321: connect: connection refused

How to fix it and run grpcui in docker?

What is the command line to run the docker? parameters? IMHO they should be described .

ZedZipDev avatar Nov 01 '21 09:11 ZedZipDev

In a docker image, the process runs on a different network interface -- a virtual network interface. So localhost doesn't work -- it only works to connect to other processes listening on the network in the same container.

Content was recently added to the README for grpcurl: https://github.com/fullstorydev/grpcurl/pull/258. I can add the same info to the README for this project, too. Relevant details below:

Note that there are some pitfalls when using docker:

  • If you need to interact with a server listening on the host's loopback network, you must specify the host as host.docker.internal instead of localhost (for Mac or Windows) OR have the container use the host network with -network="host" (Linux only).
  • If you need to provide proto source files or descriptor sets, you must mount the folder containing the files as a volume (-v $(pwd):/protos) and adjust the import paths to container paths accordingly.

jhump avatar Nov 01 '21 15:11 jhump

Ok, I have tried:

PS D:\_Docker\grpcui> docker run -it --rm -p 0.0.0.0:8180:8080 fullstorydev/grpcui:latest host.docker.internal:54321

Failed to dial target host "host.docker.internal:54321": x509: certificate is valid for localhost, not host.docker.internal

What I do wrong?

ZedZipDev avatar Nov 01 '21 16:11 ZedZipDev

@Oleg26Dev, looks like your server is using a self-signed cert that is only valid for the localhost host name. You could either have that cert generated to include host.docker.internal as an alias or you could supply the -insecure flag to the container (which means it will skip some security checks, such as the hostname validation of the server's certificate).

jhump avatar Jan 07 '22 17:01 jhump