Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client fails to run inside docker #3

Open
mipnw opened this issue Sep 17, 2020 · 1 comment
Open

client fails to run inside docker #3

mipnw opened this issue Sep 17, 2020 · 1 comment

Comments

@mipnw
Copy link

mipnw commented Sep 17, 2020

The main README.md has instructions for how to run the server and client inside docker. When I follow these instructions, I can start the server fine:

$ export HOST=grpc.nleiva.com
$ export PORT=443
$ make docker-build
...
$ make run-docker-server
docker run -t --rm \
        --name my-server \
        --publish=443:443 \
        server
level=info time=2020-09-17T17:52:10.762406133Z caller=main.go:206 msg="Server listening" port=443
level=info time=2020-09-17T17:52:10.76250748Z caller=main.go:209 msg="Starting gRPC services"
level=info time=2020-09-17T17:52:10.762551842Z caller=main.go:212 msg="Listening for incoming connections"

But in another shell, when I run the client in docker, it fails

$ export HOST=grpc.nleiva.com
$ export PORT=443
$ export ID=1
$ make run-docker-client
docker run -t --rm --name my-client -e 1 client
2020/09/17 17:53:57 HOST environment variable not set.
panic: HOST environment variable not set.

goroutine 1 [running]:
log.Panicf(0x8dff0b, 0x20, 0xc0000a3f10, 0x1, 0x1)
        /usr/local/go/src/log/log.go:340 +0xc0
main.getenv(0x8d0f0e, 0x4, 0x10, 0xc0000e8100)
        /go/src/github.com/nleiva/grpc-tls/client/main.go:32 +0xd1
main.init.ializers()
        /go/src/github.com/nleiva/grpc-tls/client/main.go:24 +0x3a
Makefile:39: recipe for target 'run-docker-client' failed
make: *** [run-docker-client] Error 2
@mipnw
Copy link
Author

mipnw commented Sep 17, 2020

The following needs to be added to the final image in client/Dockerfile

ARG host
ARG port
ENV PORT=$port
ENV HOST=$host

to fix that issue. We also need to add the root CA certificate to the final image

COPY ./ca.cert /

So "-mode 3" will work.

Also the make run-docker-client target needs to be fixed, there seems to be a problem with the -id command line argument because

$ make run-docker-client 
docker run -t --rm --name my-client -e 1 client
invalid value "$ID" for flag -id: parse error

Instead one can start the client in docker manually, bypassing make

docker run -it --rm --name my-client client ./cli -id 1 -file ./ca.cert -mode 3

But this errors with

2020/09/17 18:31:26 Server says: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp [EDITED]: i/o timeout"

This is after having edited the certificate.conf to set the CN to grpc.nleiva.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant