Siraxis
Siraxis

Reputation: 41

Apache/Nifi 1.12.1 Docker Image Issue

I have a Dockerfile based on apache/nifi:1.12.1 and want to expand it like this:

FROM apache/nifi:1.12.1
RUN mkdir -p /opt/nifi/nifi-current/conf/flow

Thing is that the folder isn't created when I'm building the image from Linux distros like Ubuntu and CentOS. Build succeeds, I run it with docker run -it -d --rm --name nifi nifi-test but when I enter the container through docker exec there's no flow dir.

Strange thing is, that the flow dir is being created normally when I'm building the image through Windows and Docker Desktop. I can't understand why is this happening.

I've tried things such as USER nifi or RUN chown ... but still...

For your convenience, this is the base image: https://github.com/apache/nifi/blob/rel/nifi-1.12.1/nifi-docker/dockerhub/Dockerfile

Take a look at this as well: This is what looks like at the CLI

Thanks in advance.

Upvotes: 1

Views: 979

Answers (1)

Tolis Gerodimos
Tolis Gerodimos

Reputation: 4400

By taking a look at the dockerfile provided you can see the following volume definition


enter image description here

Then if you run

docker image inspect apache/nifi:1.12.1

enter image description here

As a result, when you execute the RUN command to create a folder under the conf directory it succeeds

BUT when you run the container the volumes are mounted and as a result they overwrite everything that is under the mountpoint /opt/nifi/nifi-current/conf

In your case the flow directory.

You can test this by editing your Dockerfile

FROM apache/nifi:1.12.1
# this will be overriden, by volumes
RUN mkdir -p /opt/nifi/nifi-current/conf/flow
# this will be available in the container environment
RUN mkdir -p /opt/nifi/nifi-current/flow

To tackle this you could

  1. clone the Dockerfile of the image you use as base one (the one in FROM) and remove the VOLUME directive manually. Then build it and use in your FROM as base one.
  2. You could try to avoid adding directories under the mount points specified in the Dockerfile

Upvotes: 1

Related Questions