0

Suppose we have 2 swarm nodes and we want to create service A in node 1 and service B in node 2. We want /app of every service written in /mnt/XXX of every node. is there any clear solution? I wrote this but in service B in node 2 has data access problems:

version: '3'
services:
  A:
   volumes:
      - '/mnt/data:/app'
   deploy:
     placement:
       constraints:
         - "node.labels.host==A"  
  B:
   volumes:
      - '/mnt/data:/app'
   deploy:
     placement:
       constraints:
         - "node.labels.host==B"

  • How do you get the data on to every node? If you're mounting over an image's `/app` directory, would it be easier just to include the data in the image you're running? – David Maze Oct 12 '20 at 17:25
  • You can [back the `docker volume` with a Network File System share that's accessible from each node in the cluster](https://stackoverflow.com/a/64246878/1423507) then mount the `docker volume` to the containers on each node. – masseyb Oct 12 '20 at 19:30
  • @DavidMaze I'm using kafka image and I want to persist my data. so I want to mount it. – sahar ehsanpour Oct 13 '20 at 07:54
  • @masseyb I want to use kafka. nfs is not good for heavy write and I don't need shared volume(each container has its own data). each node must write its data on its local hard – sahar ehsanpour Oct 13 '20 at 07:56
  • @saharehsanpour it is what it is.. The requirement is to share the data across nodes in the cluster, only so many ways you can do that regardless of what you're putting in the shared folder, e.g. deal with it.. – masseyb Oct 13 '20 at 07:59
  • @saharehsanpour if there is no requirement to share the volumes across nodes then what exactly is your issue? Error message? Anything? Clarify "but in service B in node 2 has data access problems", access to what data? The data created by service A?... – masseyb Oct 13 '20 at 08:04

0 Answers0