Palak Chaudhary
Palak Chaudhary

Reputation: 33

Docker Stack Volume mapping

I'm trying to deploy a Docker Stack over my Swarm consisting of a manager node and a worker node, using compose yaml file.

I'm trying to run 2 services (Cardano, Nem). Cardano is to be ran on worker node (machine having IP 10.218.77.99), as given in constraint. Nem is to be ran on the manager node.

The issue I'm facing is the volume mapping for Cardano does not work and the service doesn't run. It gives error "invalid mount config for type.."

While Nem service works fine as it is running in manager node and the volume path is easily accessible.

Is my format wrong for specifying the Disk path of the worker node? Or will the stack that's running on manager node not be able to retrieve container logs of worker node?

Below is my yaml file.

version: "3.5"

services:

   Cardano:
    image: coin.azurecr.io/coin-console
    deploy:
      replicas: 2
      placement:
        constraints:
          - node.labels.machine==10.218.77.99
    command: ["BlockTime", "Cardano"]
    volumes:
      - /COINIANPDDisk/blocktime/cardano/logs:/logs

   Nem:
    image: coin.azurecr.io/coin-console
    deploy:
      replicas: 2
    command: ["BlockTime", "Nem"]
    volumes:
      - /COINIANPDDisk1/blocktime/Nem/logs:/logs

Appreciate your help.

Upvotes: 1

Views: 929

Answers (1)

Chris Becke
Chris Becke

Reputation: 36026

If I am reading your question right, it seems you are trying to mount a network share as a volume.

docker, being linux based, does not support implicit mounting of smb based shares. The equivalent functionality is nfs, so first share the desired folders using nfs, and then, the correct compose syntax to access a nfs share would be:

volumes:
  nfs_volume:
    driver: local
    driver_opts:
      type: nfs
      o: addr=192.168.1.1,rw
      device: ":/path/to/dir"

Use an NFS Share

Using it as a normal docker volume:

services:
  Cardano:
    image: coin.azurecr.io/coin-console
    volumes:
      - nfs_volume:/logs

Note: While this simple brute force approach to mounting nfs shares does work with minimal extra requirements, other distributed filesystems such as glusterfs are necessary for certain database tasks where nfs can't pfovide the lock guarantees / other low level capabilities.
Also volume plugins are available that can manage the creation and mounting of networked volumes automatically.

Upvotes: 0

Related Questions