Giter VIP home page Giter VIP logo

docker-mergerfs's Introduction

docker-mergerfs

buildx

Docker image for pooling filesystem mergerfs mount or unionfs mount, with

  • Ubuntu 20.04
  • some useful scripts

Usage

version: '3'

services:
  rclone:
    container_name: mergerfs
    image: slink42/mergerfs
    restart: always
    network_mode: "bridge"
    volumes:
      - /your/mount/points/parent/folder:/mnt:rshared
    devices:
      - /dev/fuse
    cap_add:
      - SYS_ADMIN
    security_opt:
      - apparmor:unconfined
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=Australia/Sydney
      - MERGED_DEST=/mnt/data
      - MFS_BRANCHES=/mnt/local1=NC:/mnt/local12=NC:/mnt/local13=NC

equivalently,

docker run -d \
    --name=mergerfs \
    --cap-add SYS_ADMIN \
    --device /dev/fuse \
    --security-opt apparmor=unconfined \
    -v /your/mount/points/parent/folder:/mnt:shared \
    -e PUID=${PUID} \
    -e PGID=${PGID} \
    -e TZ=Australia/Sydney \
    -e MERGED_DEST=/mnt/data \
    -e MFS_BRANCHES=/mnt/local1=NC:/mnt/local12=NC:/mnt/local13=NC \
    slink42/mergerfs

First, you need to prepare folders to merge within volume bind mount(s).

mkdir -p /your/mount/points/parent/folder/local1
echo 'test file contents' > /your/mount/points/parent/folder/local1/test1
mkdir -p /your/mount/points/parent/folder/local2
echo 'test file contents' > /your/mount/points/parent/folder/local2/test2
mkdir -p /your/mount/points/parent/folder/local3
echo 'test file contents' > /your/mount/points/parent/folder/local3/test3

Then, setup and run your container with a proper environment variable MFS_BRANCHES which specifies an branches to merge using mergerfs. Then check the logs to see if you got it right

docker logs <container name or sha1, e.g. mergerfs>

mergerfs mount

Here is the internal command for mergerfs mount.

mergerfs \
    -o uid=${PUID:-911},gid=${PGID:-911},umask=022,allow_other \
    -o ${MFS_USER_OPTS} \
    /mnt/local=RW:/mnt/cloud=NC ${MERGED_DEST}

where a default value of MFS_USER_OPTS is

MFS_USER_OPTS="rw,use_ino,func.getattr=newest,category.action=all,category.create=ff,cache.files=auto-full,dropcacheonclose=true"

and the default value of MERGED_DEST is /mnt/data

Please note that variables only with capital letters are configurable by environment variables. Also, be aware that rc is enabled by default.

ENV Description Default
PUID / PGID uid and gid for running an app 911 / 911
TZ timezone, required for correct timestamp in log
MERGED_DEST local container path to merged output folder /mnt/data
POOLING_FS pooing fs to use, mergerfs or unionfs mergerfs
MFS_BRANCHES source banches config to pass to mergerfs /mnt/local=RW:/mnt/cloud=NC
UFS_BRANCHES source banches config to pass to unionfs /mnt/local=RW:/mnt/cloud=RO

If you want unionfs instead of mergerfs, set POOLING_FS=unionfs, which will apply

unionfs \
    -o uid=${PUID:-911},gid=${PGID:-911},umask=022,allow_other \
    -o ${UFS_USER_OPTS} \
    /mnt/local=RW:/mnt/cloud=RO ${MERGED_DEST}

where the default value of UFS_USER_OPTS is

UFS_USER_OPTS="cow,direct_io,nonempty,auto_cache,sync_read"

and the default value of MERGED_DEST is /mnt/data

Credit

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.