1

I'm using a Digital Ocean docker droplet and have 3 docker containers: 1 for front-end, 1 for back-end and 1 for other tools with different dependencies, let's call it back-end 2.

The front-end calls the back-end 1, the back-end 1 in turn calls the back-end 2. The back-end 2 container exposes a gRPC service over port 50051. Locally, by running the following command, I was able to identify the docker service to be running with the IP 127.17.0.1:

docker network inspect bridge --format='{{json .IPAM.Config}}'

Therefore, I understand that my gRPC server is accessible from the following url 127.17.0.1:50051 within the server.

Unfortunately, the gRPC server refuses connections when running from the docker droplet while it works perfectly well when running locally.

Any idea what may be different?

Peteris
  • 3,548
  • 4
  • 28
  • 44
  • 1
    Using the Docker-internal IP addresses is pretty much always wrong...but I'm guessing you swapped two digits and the Docker private network is 172.17.0.0/16, local to this specific host. https://stackoverflow.com/questions/30545023/how-to-communicate-between-docker-containers-via-hostname is the much better answer. – David Maze Jul 04 '18 at 01:04
  • This is great, problem solved - do you want to add this as an official answer @DavidMaze? – Peteris Jul 04 '18 at 14:11

3 Answers3

1

You should generally set up a Docker private network to communicate between containers using their container names; see e.g. How to communicate between Docker containers via "hostname". The Docker-internal IP addresses are subject to change if you delete and recreate a container and aren't reachable from off-host, and trying to find them generally isn't a best practice.

172.17.0.0/16 is a typical default for the Docker-internal IP network (127.0.0.0/8 is the reserved IPv4 loopback network) and it looks like you might have typoed the address you got from docker network inspect.

David Maze
  • 130,717
  • 29
  • 175
  • 215
0

Try docker run with following command:

docker run -d -p {server ip}:12345 {back-end 2 image}

It will expose IP port to docker container and will be accessible from other servers.
Note: also check firewall rules, if firewall is blocking access.

Akash Sharma
  • 721
  • 3
  • 6
0

You could run docker binding to ip and port as shown by Aakash. Please restrict access to this specific IP and port to be accessed only from the other docker IP and port - this will help to run docker private and doesn't allow other (even the other docker/instances within your network).

  • I don't see any Aakash answer. – Jeroen Heier Jul 17 '18 at 03:43
  • Akash said below: Try docker run with following command: docker run -d -p {server ip}:12345 {back-end 2 image} It will expose IP port to docker container and will be accessible from other servers. Note: also check firewall rules, if firewall is blocking access. – Santhosh Sundarasamy Jul 18 '18 at 09:38