vieux / docker-volume-sshfs

sshfs docker volume plugin
MIT License
592 stars 104 forks source link

Using IdentityFile setting with docker-compose #68

Open guysoft opened 5 years ago

guysoft commented 5 years ago

Hey, How would I do use an IdentityFile setting with docker-compose? I tried:

  sshdata:
    driver: vieux/sshfs:latest
    driver_opts:
      sshcmd: "ubuntu@host:/path"
      IdentityFile: /home/ubuntu/.ssh/key_file
      allow_other: ""

But did not seem to work

Neither did:

  sshdata:
    driver: vieux/sshfs:latest
    driver_opts:
      sshcmd: "ubuntu@host:/path -o identityfile=/home/ubuntu/.ssh/key_file"
      allow_other: ""

I get:


ERROR: for test_container Cannot start service test_service: error while mounting volume '': VolumeDriver.Mount: sshfs command execute failed: exit status 1 (read: Connection reset by peer
geoffmyers commented 5 years ago

I am experiencing the same issue:

ERROR: for plex  Cannot create container for service plex: VolumeDriver.Mount: sshfs command execute failed: exit status 1 (SSHFS version 2.10
read: Connection reset by peer
)
ERROR: Encountered errors while bringing up the project.

Please advise. Thanks for any help!

More details:

volumes:
    videos:
        driver: vieux/sshfs:latest
        driver_opts:
          allow_other: ""
          IdentityFile: "/home/$USER/.ssh/$KEY"
          sshcmd: "$USER@$HOST:/mnt/Videos"
          sshfs_debug: ""
geoffmyers commented 5 years ago

This solved the issue for me.

guysoft commented 5 years ago

I moved to using a password and it seems to work well as a workaround for me.

I can't touch it now because I have production stuff mounted. So if you want you can close this. I might be able to test, but not soon.

rcarmo commented 4 years ago

I've been trying my hand at this, and @geoffmyers' suggestion to look at #58 did not work for me.

I have tried enough times that I set up a Makefile to completely reset the plugin:

bootstrap:
    -docker plugin rm -f vieux/sshfs:latest
    -sudo rm -f /var/lib/docker/plugins/sshfs-state.json
    docker plugin install vieux/sshfs:latest DEBUG=1 sshkey.source=$(HOME)/.ssh/

...and have added all conceivable debug options to the docker-compose file:

incoming:
    driver: vieux/sshfs:latest
    driver_opts:
      sshcmd: "foo@bar:/baz"
      IdentityFile: "/root/.ssh/id_rsa"
      port: 2211
      reconnect: ""
      allow_other: ""
      sshfs_debug: ""

...and docker plugin inspect looks OK:

 {
                    "Description": "",
                    "Destination": "/root/.ssh",
                    "Name": "sshkey",
                    "Options": [
                        "rbind"
                    ],
                    "Settable": [
                        "source"
                    ],
                    "Source": "/home/ubuntu/.ssh/",
                    "Type": "bind"
                }

What I see in journalctl -f -u docker.service is this:

Jan 25 18:37:08 media dockerd[1319]: time="2020-01-25T18:37:08Z" level=error msg="time=\"2020-01-25T18:37:08Z\" level=debug msg=\"&volume.MountRequest{Name:\\\"dockerplexstack_incoming\\\", ID:\\\"5f2b631170deed6c08a149bff4ddcaaf9b00b49f6581ab93467149536646e921\\\"}\" method=mount" plugin=8ebce3397061512328dc23c9214ad11f284286d713ef1ede56ce317f5cfb4904
Jan 25 18:37:08 media dockerd[1319]: time="2020-01-25T18:37:08Z" level=error msg="time=\"2020-01-25T18:37:08Z\" level=debug msg=\"[sshfs -oStrictHostKeyChecking=no foo@bar:/baz /mnt/volumes/c42c64e0c7cca29067351251cf10f8f7 -p 2211 -o sshfs_debug -o IdentityFile=/root/.ssh/id_rsa -o allow_other -o loglevel=debug -o reconnect]\"" plugin=8ebce3397061512328dc23c9214ad11f284286d713ef1ede56ce317f5cfb4904
Jan 25 18:37:08 media dockerd[1319]: time="2020-01-25T18:37:08Z" level=error msg="time=\"2020-01-25T18:37:08Z\" level=error msg=\"sshfs command execute failed: exit status 1 (SSHFS version 2.10\\nread: Connection reset by peer\\n)\"" plugin=8ebce3397061512328dc23c9214ad11f284286d713ef1ede56ce317f5cfb4904
Jan 25 18:37:08 media dockerd[1319]: time="2020-01-25T18:37:08Z" level=error msg="time=\"2020-01-25T18:37:08Z\" level=error msg=\"sshfs command execute failed: exit status 1 (SSHFS version 2.10\\nread: Connection reset by peer\\n)\"" plugin=8ebce3397061512328dc23c9214ad11f284286d713ef1ede56ce317f5cfb4904
Jan 25 18:37:08 media dockerd[1319]: time="2020-01-25T18:37:08.220581823Z" level=error msg="992dc92fc606c10696ccd0a6cadac8d82d7cffda95a7baf50a154ef55a8a12d5 cleanup: failed to delete container from containerd: no such container"

So I'm apparently setting the key properly (since the bind mount is there), but have no real way to debug this. And yes, the key in question works, and I can do regular sshfs mounts with it.