Giter Site home page Giter Site logo

mergerfs-docker's Introduction

mergerfs-docker

build Shiny%20version Docker Pulls Docker Image Size (latest by date)

All credit goes to trapexit/mergerfs.

Motivation

If you are here, then you are most likely looking for a simple solution to fuse multiple hard drives' contents to a single mountpoint using mergerfs and docker. There are multiple containers which dockerize mergerfs, however none are regularly updated, with open-sourced dockerfiles (no crypto-miners) and simple to use. This repository attempts to do just that. Simply mount your hard drives as volumes to /disks and mergerfs will make them available under /merged. Exposing the /merged volume to host, you need to use :shared bind to share it between the container and host. Change the volume path on the host to your prefered location and that's it!

How to run it

Docker run:

docker run -v /mnt/nd1:/disks/nd1 -v /mnt/nd2:/disks/nd2 -v /mnt/nd3:/disks/nd3 -v /mnt/merged:/merged:shared --device /dev/fuse --cap-add SYS_ADMIN -d hvalev/mergerfs

docker-compose:

services:
  mergerfs:
    image: hvalev/mergerfs:latest
    container_name: mergerfs
    cap_add:
      - SYS_ADMIN
    devices:
      - /dev/fuse:/dev/fuse
    volumes:
       - /mnt/nd1:/disks/nd1
       - /mnt/nd2:/disks/nd2
       - /mnt/nd3:/disks/nd3
       - /mnt/merged:/merged:shared
    restart: always

Customizing

  • If you would like to customize the mergerfs command with additional options, you can overwrite parameters.conf with your own using an additional volume mount that maps onto /config inside the docker. You can use the one in the repo as a template.
  • You can also override the default mergerfs parameters by using the MERGERFS_PARAMS environment variable as follows:
services:
  mergerfs:
    image: hvalev/mergerfs:latest
    container_name: mergerfs
    environment:
      MERGERFS_PARAMS: 'moveonenospc=true,dropcacheonclose=true,category.create=mfs,cache.files=partial'
    cap_add:
      - SYS_ADMIN
    devices:
      - /dev/fuse:/dev/fuse
    volumes:
       - /mnt/nd1:/disks/nd1
       - /mnt/nd2:/disks/nd2
       - /mnt/nd3:/disks/nd3
       - /mnt/merged:/merged:shared
    restart: always
  • If you would like to combine this with samba to share it over the network, you could also use a samba docker container. Below is an example with a sample user read-write and guest read-only access.
services:
  mergerfs:
    image: hvalev/mergerfs:latest
    container_name: mergerfs
    environment:
      MERGERFS_PARAMS: 'moveonenospc=true,dropcacheonclose=true,category.create=mfs,cache.files=partial'
    cap_add:
      - SYS_ADMIN
    devices:
      - /dev/fuse:/dev/fuse
    volumes:
      - /mnt/hd1:/disks/hd1
      - /mnt/hd2:/disks/hd2
      - /mnt/hd3:/disks/hd3
      - /mnt/hd:/merged:shared
    restart: always

  samba:
    image: elswork/samba:3.2.8
    container_name: samba
    environment:
      TZ: 'Europe/Amsterdam'
    ports:
      - 139:139
      - 445:445
    volumes:
      - /mnt/hd:/mnt/hd
    command: '-u "1000:1000:user:user:user_password" 
              -u "1000:1000:guest:guest:guest_password"
              -s "hd:/mnt/hd:rw:user"
              -s "media:/mnt/hd:ro:guest"'
    restart: unless-stopped
    depends_on:
      - mergerfs

Acknowledgements

The following resources have been extremely helpful:

Licence

mergerfs itself has the following licence:

/*
  ISC License

  Copyright (c) 2016, Antonio SJ Musumeci <[email protected]>

  Permission to use, copy, modify, and/or distribute this software for any
  purpose with or without fee is hereby granted, provided that the above
  copyright notice and this permission notice appear in all copies.

  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

https://github.com/trapexit/mergerfs/blob/master/LICENSE

mergerfs-docker's People

Contributors

dependabot[bot] avatar hvalev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

mergerfs-docker's Issues

umount before mount ?

Hi,

sorry, I am really new to linux and docker...

Got your container working.. Thanks for this :-)

I had 2 or 3 times the problem that the container was shut down for a moment while mounting disks on my qnap.
After that the container does not start again, because the mount already exists.

Fehler 2023-08-21 08:46:10 admin --- Container Station Docker Engine - Community / 20.10.22-qnap7 Container Station Containers [Container Station] Failed to start container "mergerfs". Error message: Error response from daemon: error while creating mount source path '/share/Alle-Medien/Alle-Medien': mkdir /share/Alle-Medien/Alle-Medien: file exists

Can I change the yaml in that way, that a possible mount is unmounted before ?

Mike

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.