How to connect nifi & nifi registry using docker network

1k Views Asked by At

I have a container running nifi (--name nifi) exposing port 8080 and another container running nifi registry (--name nifireg) exposing port 10808. I can get to both UI's, and I am able to connect nifi to the registry in the registry services by using the registry container's IP (172.17.0.5). These containers are also on a docker network called nifi-net. My issue is that the registry client is unable to talk to the registry when using the container name.

From the nifi I can ping by container IP as well as by name (ping nifireg), so there is some level of connectivity. But if I change the registry client to point to http://nifireg:180880 or even http://nifi-net.nifireg:18080 it clocks for a while and then eventually returns this error:

Unable to obtain listing of buckets: java.net.ConnectException: Connection refused (Connection refused)

What needs to be done to allow nifi to connect to the nifi registry using the container name?

EDIT: Here is how I set everything up:

docker run -d --name nifi -p 8080:8080 apache/nifi
docker run -d --name nifireg -p 18080:18080 apache/nifi-registry

I added the netorking after the fact, but that shouldn't be an issue.

docker network create nifi-net
docker network connect nifi-net nifi
docker network connect nifi-net nifireg
2

There are 2 best solutions below

0
supahcraig On

I don't understand why this solved the problem, but destroying the containers and recreating them with the --net nifi-net option at spin-up solved the problem.

docker run -d --name nifi --net nifi-net -p 8080:8080 apache/nifi
docker run -d --name nifireg --net nifi-net -p 18080:18080 apache/nifi-registry

The docs state that you can add them to a network after the fact, and I am able to ping from one container to the other using the name. I guess it's just a lesson that I need to use docker networking more.

0
mumf On

I would suggest using docker-compose to manage the deployment since you can define the network once in docker-compose.yaml and not have to worry about it agian.

Plus it lets you learn about docker networking :P