1

Straight to the point. I've been trying to move some microservices inside docker containers. For simplicity, suppose you have two microservices on the same machine, call it A and B. Both microservices use gRPC. The microservice A wants to call a procedure inside B. B is inside a docker container and it is on the same machine where A is running but not in a container. When A calls a procedure, I get rpcerror: code = Unavailable desc = connection closed.

I've launched B with: docker run -it -p 51001:51001 B

This is the Dockerfile

FROM golang as builder
WORKDIR /go/src/b
RUN \
    git clone bla bla bla bla /go/src/b \
    && GOOS=linux GOARCH=amd64 \
    go get && CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o main .
FROM alpine:latest
RUN apk --no-cache add ca-certificates && apk add --update bash
WORKDIR /root/
COPY --from=builder /go/src/b/main .
COPY --from=builder /go/src/b/.env .
EXPOSE 51001
CMD ["./main"]

I've checked the ports and everything looks fine, both inside the container and on the host machine.

My host machine ships MacOS.

When launched without containers, everything works fine. So it has something to do with docker, grpc with docker, some network stuff, or it may be even 42... dunno. Someone?

If you need some other info, just ask.

2 Answers2

0

I ran into this as well, for me I could fix it using

docker run -it --network host [...]

this is of course not an actual fix, just that docker network controller is throwing connections.

Maybe a fix is to update your docker installation.

0

Ran into a similar issue. Not sure how you set up your gRPC server, but changing the listener's address from localhost:51001 to :51001 fixed it for me.

Better explained here.

jsfpdn
  • 73
  • 1
  • 6