Error Mounting CIFS/SMB Volume in Docker Compose: Invalid Argument

Hi everyone,

I’m relatively new to using the SMB method and am trying to mount data from a remote server. I found a solution at this link, but I’m encountering issues when running my Docker Compose file. The data is accessible via SMB without requiring a username and password.

Here are my Docker and Docker Compose versions:

$ docker --version
Docker version 24.0.5, build 24.0.5-0ubuntu1~20.04.1

$ docker-compose --version
Docker Compose version v2.27.1

Manually mounting works fine with:

$ sudo mount -t cifs //<remote-server>/example/path/ /home/user/data/
Password for root@//<remote-server>/example/path/:********

Here’s my docker-compose.yml:

services:
  test:
    image: nvidia/cuda:12.3.1-base-ubuntu20.04
    command: nvidia-smi
    volumes:
      - face-recognition-data:/example/path
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

volumes:
  face-recognition-data:
    driver: local
    driver_opts:
      type: cifs
      o: uid=1000,gid=1000,vers=3.0
      device: "//<remote-server>/example/path"

When I run docker-compose run test bash, I get the following error:

Error response from daemon: error while mounting volume '/var/lib/docker/volumes/test_face-recognition-data/_data': failed to mount local volume: mount //<remote-server>/example/path:/var/lib/docker/volumes/test_face-recognition-data/_data, data: uid=1000,gid=1000,vers=3.0: invalid argument

Once the Docker Compose setup works, I plan to verify data presence in the container with:

cd /example/path
ls -la

Any help or suggestions to resolve this issue would be greatly appreciated!. Thank you.

Make sure to use docker compose and not legacy docker-compose.

Yes, but I am still getting the same issue, i.e., an invalid argument.