Persistent data in stack deploy

What is wrong with below code? i have 2 services wordpress &mysql and i want to persist data in 2 node swarm cluster when i deploy through docker stack deploy. I’m using bind mounts as named mounts are not persisting data. I have also restricted wordpress to manager and sql to worker so they create bind mounts in their own nodes and thus persist data. or am i completely wrong? Kindly help. While stack deployment i get an error as “invalid mount config for type…”

version: '3.3'
services:
  wordpress:
    image: wordpress
    depends_on:
      - mysql
    ports:
      - 8080:80
    deploy:
      replicas: 2
      restart_policy:
        condition: on-failure
      placement:
        constraints:
          - node.role == manager 
    environment:
      WORDPRESS_DB_HOST: mysql
      WORDPRESS_DB_NAME: wordpress
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
    volumes:
      - /wordpress-data:/var/www/html
    networks: 
      - my_net
  mysql:
    image: mariadb
    deploy:
      replicas: 1
      restart_policy:
        condition: on-failure
      placement:
        constraints:
          - node.role == worker 
    environment:
      MYSQL_ROOT_PASSWORD: wordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress    
    volumes:
      - /mysql-data:/var/lib/mysql
    networks: 
      - my_net
networks:
  my_net:

Hi @Vikram
We 're trying to make this course very simple to match who doesn’t have any experience in Docker. We discussed Docker-Swarm in details in our Docker advanced course :