Setting up Samba share in docker. What is purpose of mounting a volume vs -s?
Set up a dperson/samba container in docker on Ubuntu server. In order to set up a share I used the following command in the compose file: command: '-p -u "user1;badpass" -s "etl_share;/mount/etl_share;no;no;no;user1"'
which mounts a share called etl_share
that is located at /mnt/etl_share
on the host. This works fine. But I also see in some docs that they use -v
to mount a volume. Why do that in addition to -s
?
Docker run from Docs:
sudo docker run -it -p 139:139 -p 445:445 -d dperson/samba -p \
-u "example1;badpass" \
-u "example2;badpass" \
-s "public;/share" \
-s "users;/srv;no;no;no;example1,example2" \
-s "example1 private share;/example1;no;no;no;example1" \
-s "example2 private share;/example2;no;no;no;example2"
Docker-compose from docs:
services: samba: image: dperson/samba environment: TZ: 'EST5EDT' networks: - default ports: - "137:137/udp" - "138:138/udp" - "139:139/tcp" - "445:445/tcp" read_only: true tmpfs: - /tmp restart: unless-stopped stdin_open: true tty: true volumes: - /mnt:/mnt:z - /mnt2:/mnt2:z command: '-s "Mount;/mnt" -s "Bobs Volume;/mnt2;yes;no;no;bob" -u "bob;bobspasswd" -p'
Comments Section
-v is first used to mount the volume in the container
-s is used later, 'command:' runs the command at container launch, inside of the container. -s tells samba to share the directory
if you only have -v, then you have the directory available in the container, but you didn't tell samba to do anything with it, so it won't show up in samba
if you have only -s, then the container can't see the directory mounted in -v. You would probably get an error like "directory not found"
The thing is, I am not using -v, only -s and i can see the directory just fine, which is why I am confused.