Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Using IdentityFile setting with docker-compose #68

Open
guysoft opened this issue Mar 26, 2019 · 4 comments
Open

Using IdentityFile setting with docker-compose #68

guysoft opened this issue Mar 26, 2019 · 4 comments

Comments

@guysoft
Copy link

guysoft commented Mar 26, 2019

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
Copy link

geoffmyers commented Mar 27, 2019

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:

  • vieux/sshfs:latest
  • Docker version 18.09.2, build 6247962
  • Ubuntu 18.10
  • I am able to successfully connect to the remote SSH server from the Docker host using the appropriate key in ~/.ssh, which is defined in my docker-compose.yml:
volumes:
    videos:
        driver: vieux/sshfs:latest
        driver_opts:
          allow_other: ""
          IdentityFile: "/home/$USER/.ssh/$KEY"
          sshcmd: "$USER@$HOST:/mnt/Videos"
          sshfs_debug: ""

@geoffmyers
Copy link

This solved the issue for me.

@guysoft
Copy link
Author

guysoft commented Mar 28, 2019

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
Copy link

rcarmo commented Jan 25, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants