0

I have the below cassandra-compose.yml file which I am trying to deploy on a docker swarm with the below command.

  docker stack deploy --compose-file=cassandra-compose.yml cassandra-service

Issue:-

The Service is getting created but no replicas are running.When I inspected the issue, I found that because the mounted folder ie. ~/user/cassandraBackup is not present and that is why the container isn't started.

I tried to run it using docker-compose and it got executed successfully. Can somebody tell me how to run it using stack-deploy

Cassandra-compose.yml:-

  version: '3.1'
  services:

  multinode:
    image: cassandra:3.9
    deploy:
        replicas: 2
    volumes:
        - ~/user/cassandraBackup/:/var/lib/cassandra/data
    ports:
        - 7000:7000
        - 7001:7001
        - 7199:7199
        - 9042:9042
        - 9160:9160
Arun Kumar
  • 21
  • 3
  • It is running successfully with docker-compose, but i just want it to run by using docker stack deploy only – Arun Kumar Aug 08 '18 at 07:14
  • Possible duplicate of [Getting invalid mount config for type "bind": bind source path does not exist in docker](https://stackoverflow.com/questions/48971065/getting-invalid-mount-config-for-type-bind-bind-source-path-does-not-exist-in) – Andrii Litvinov Feb 22 '19 at 14:11

2 Answers2

2

try using this command :-

docker stack deploy --compose-file=cassandra-compose.yml -f cassandra-compose.yml cassandra-service

It will get your issue resolved

Dhiresh Budhiraja
  • 2,575
  • 5
  • 17
  • 26
  • 2
    when i'm running this command it throughs the error:- unknown shorthand -f, i think there is no command like this – Arun Kumar Aug 08 '18 at 10:55
0

From this answer https://stackoverflow.com/a/48972713/2138959:

Docker Swarm BIND MOUNTS

If you bind mount a host path into your service’s containers, the path must exist on every swarm node. The Docker swarm mode scheduler can schedule containers on any machine that meets resource availability requirements and satisfies all constraints and placement preferences you specify.

So you have to make sure the path is available to every node in the cluster the task can be scheduled to. But even with this approach container can be scheduled to a node with no or outdated data. So it is better to pin services to concrete nodes.

Andrii Litvinov
  • 12,402
  • 3
  • 52
  • 59