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.