docker-nifi icon indicating copy to clipboard operation
docker-nifi copied to clipboard

Volumes not save flows

Open Wilton opened this issue 7 years ago • 4 comments

Processors are not saved after to and restart the containers, whenever I see the volume database_repository it is modified. I need to create the flows and they stay on the volume. And I have a question regarding clusters volumes, how should I implement them? Should I make a volume for each instance or can I just create a shared volume for all instances?

Wilton avatar Nov 02 '18 23:11 Wilton

Docker containers should be stateless. Thus all container-related parameters (configuration, processors etc.) should be managed on docker image build stage. But, certainly, you can mount your custom processor as volume

Flow management is a pain-point for NiFi. Here you have 2 options:

  • mark flow.xml.gz as volume
  • use NiFi-Registry subproject

Easiest way to work with flow which is stored outside of container:

  1. Create folder with NiFi configuration (use your own local path)
docker run --name nifi -d xemuliam/nifi && \
docker cp nifi:/opt/nifi/conf /Users/xemuliam/Projects/Docker/nifi_test && \
docker rm -f nifi && \
ls -la /Users/viacheslav.kalashnikov/Projects/Docker/nifi_test/conf
  1. Run NiFi with folder from previous step mounted as volume docker run --name nifi -d -p 8080 -v /Users/xemuliam/Projects/Docker/nifi_test/conf:/opt/nifi/conf xemuliam/nifi
  2. Make some changes in flow
  3. Drop container docker rm -f nifi
  4. Run fresh NiFi container with mounted configuration folder docker run --name nifi -d -p 8080 -v /Users/xemuliam/Projects/Docker/nifi_test/conf:/opt/nifi/conf xemuliam/nifi
  5. Voila! Your changes are there!

xemuliam avatar Nov 05 '18 09:11 xemuliam

Regarding cluster

the best way is to store all node-related information (flow, settings etc.) on separate places. this approach will let you avoid any issues and contention for file-based resources (e.g. flow)

xemuliam avatar Nov 05 '18 13:11 xemuliam

@xemuliam I am following your approach. I started with copying only flow.xml.gz and nifi.properties, then starting up a new container mapping just these 2 files. The container will not start however. It has these messages in the log:

sed: cannot rename /opt/nifi/nifi-current/conf/sedTNxUtT: Device or resource busy
replacing target file  /opt/nifi/nifi-current/conf/nifi.properties

and

Caused by: java.nio.file.FileSystemException: ./conf/flow.xml.gz: Device or resource busy

sylnsr avatar Dec 19 '19 22:12 sylnsr

Also .. if the flow data is in flow.xml.gz then whats the point of the flowfile_repository folder?

sylnsr avatar Dec 19 '19 22:12 sylnsr