3
votes

I'm trying to do something very simple: use the official NiFi docker image (https://hub.docker.com/r/apache/nifi/) to run a very simple NiFi "Hello World" tutorial (https://github.com/drnice/NifiHelloWorld).

The problem is that I cannot access the port of the HandleHttpRequest processor from that tutorial (called Nifi-WebServer-HandleHTTP). The port is 6688.

I've mapped port 6688 to localhost, which I've confirmed in portainer: Portainer Snapshot Showing port mappings

The URL localhost:8080 works fine, I can access the NiFi UI and interact with it.

But when I try localhost:6688, I get an error (empty response from server).

More info

1) When I log in through Portainer to the "nifi3" container console, I can run "curl localhost:6688", and get the expected result (some HTML coming back).

2) I've confirmed via netstat that nothing else is using 6688 on my host.

3) Full container run command:

docker run --name nifi4 -d -p 8080:8080 -p 6688:6688 -p 9998:9998 -v `C:/temp/GitHub/NifiHelloWorld/Archive`:/mnt/nifi_hello_world -v C:/temp/nifi_out:/mnt/nifi_out nifi3 -v 4a8bd6cab08f08af457001810a312816757f40a7c16d2583dd6a9eabfd76db78:/opt/nifi/nifi-current/conf

So the HTTP server seems to be up on the correct port inside the container, the port mapping is there, but I cannot access it from outside.

Anyone know why?

1
I do not understand stackoverflow.com/a/43244765/348975, but does it answer your question?emory
@emory I did publish the port with -p 6688:6688. I will edit the question to include that. I'll try the -p 0.0.0.0:6688:6688 approach, but I'm not sure why it would be needed, since the port 8080 works correctly without the IP address.MG83
@emory Actually looks like they are equivalent: link to clarificationMG83
Neither would I know why 0.0.0.0 would be needed, but you were wise to try. Can you try something like docker network create test_it && docker network connect --alias mycontainer testit nifi4. Then from another container also connected to the test_it network see if you can access nifi. I have no idea why it would work and port forwarding would not, but this is what I would try next.emory
@emory Did not work from other containers either, because of the "localhost" binding in the NiFi processor itself (see the accepted answer). I do appreciate your responses, I learned about creating networks and assigning containers to them in docker!MG83

1 Answers

3
votes

It looks like you were hit with a bit of container inception. The template you are using specifies a hostname for the HandleHttpRequest processor of "localhost". Accordingly, it will only accept requests on the loopback interface internal to the container instance.

Template Configuration

You will need to remove this from your template instance such that it can bind to all interfaces and allow the port forwarding to work as expected via the docker command arguments.