sshfs

Retour

install

apt-get install sshfs

put this in crontab

@reboot /root/mountsshfs.sh

create script

emacs /root/mountsshfs.sh
sleep 10
mkdir /mnt/droplet
sshfs -o allow_other,default_permissions,IdentityFile=~/.ssh/id_rsa root@localhost:/ /mnt/droplet

remove mount

umount /mnt/droplet

sshfs docker plugin

docker plugin install vieux/sshfs
docker plugin disable vieux/sshfs
docker plugin set vieux/sshfs sshkey.source=/root/.ssh/
docker plugin enable vieux/sshfs
docker inspect vieux/sshfs

test

docker volume create -d vieux/sshfs --name sshvolume -o sshcmd=root@flatbay.fr:/root/docker/flatbay/uploads -o IdentityFile=/root/.ssh/id_rsa
docker run --rm -it -v sshvolume:/testfolder busybox ls /testfolder

equivalent docker compose

version: "3.3"

# docker exec -ti test ls /mount

services:
    test:
        image: busybox
        restart: always
        container_name: test
        volumes:
            - sshflatbaytest:/mount
        command: sleep 10000

volumes:
    sshflatbaytest:
        # name: sshflatbay
        # external: true
        driver: vieux/sshfs:latest
        driver_opts:
            sshcmd: "root@flatbay.fr:/root/test"
            IdentityFile: "/root/.ssh/id_rsa"
            # allow_other: ""
            # default_permissions: ""