Article Image
read

Recently I had a need to mount a CIFS volume as a docker volume: The summary is that I wanted to use photoview to index photos on my NAS. This led to a lot of google searching, which ultimately told me it was perfectly possible, but not a lot of detail on the how.

Requirements

If you're on linux, make sure to: sudo apt-get install cifs-utils

Word of Warning

The biggest difference between doing this in docker and using a simple mount -t cifs is that the docker mount point must be the IP address and can't be the hostname. Some googling eventually told me that this may be due to restrictions in the kernel, but I haven't verified myself.

Example

Command

docker volume create \
  --driver local \
  --opt type=cifs
  --opt device=//192.168.8.103/public \ # IMPORTANT: This must be an IP, can't be a hostname
  --opt "o=username=guest,password=guest" \
  cifstest

docker run -it --rm -v cifstest:/mnt busybox

docker-compose

And bonus photoview docker-compose stack behind traefik!

version: '3.5'

services:
    photoview:
        image: viktorstrate/photoview:2
        restart: always
        networks:
            - traefik-bridge
        volumes:
            - db:/app/db
            - cache:/app/cache
            - photos:/photos
        environment:
            - PHOTOVIEW_DATABASE_DRIVER=sqlite
            - PHOTOVIEW_SQLITE_PATH=/app/db/photoview.db
            - PHOTOVIEW_LISTEN_PORT=80
            - PHOTOVIEW_MEDIA_CACHE=/app/cache
            - MAPBOX_TOKEN=xxx
        labels:
            - "traefik.http.routers.photoview.rule=Host(`photoview`)"

volumes:
    db: {}
    cache: {}
    photos:
        driver: local
        driver_opts:
            type: cifs
            device: //192.168.8.131/public
            o: username=guest,password=guest,ro

networks:
    traefik-bridge:
        external: true
        name: traefik-bridge

See Also

  • https://forums.docker.com/t/docker-volume-create-with-local-cifs-driver/41226
  • https://github.com/moby/moby/pull/39250
Blog Logo

Christopher LaPointe


Published

Interested in Related Posts from this Site?

Virtual PDF Network Printer

May 04, 2023: For my [paperless-ngx](https://github.com/paperless-ngx/paperless-ngx) install, I wanted to be able to easily "print" to it from...

Set up your own mailserver with Maddy

February 10, 2022: About a year ago I wanted to expand beyond namecheap's simple "email forwarding" service and...

Extracting a Certificate from Traefik/acme.json

February 04, 2022: It's a fairly common need to extract a certificate and key from traefik to use...

Self-Hosted Analytics: Docker & Privacy-First

July 02, 2021: I have a lot of little sites. Probably too many. Includes various personal sites, sites...

Docker Swarm Registry and Auto Garbage Collection on NFS

March 15, 2021: After moving Traefik to v2, I also updated the common registry infrastructure. Namely, this stack...

Image

Chris LaPointe

Another site of Code

Back to Overview