pschmitt / docker-sshfs

Docker container to mount directories via SSH. For CoreOS Container Linux.
GNU General Public License v3.0
13 stars 13 forks source link

Traps not working #2

Open RyanEwen opened 5 years ago

RyanEwen commented 5 years ago

I noticed that after the container is stopped/killed/removed the mount point is made unusable and the next time you start the container it will fail. I have to sudo umount the mount from my host in order to have things work again.

As far as I can tell this is because the traps are not working in the entrypoint script. I've been playing around but unable to get the trap function to ever become executed.

pschmitt commented 5 years ago

My workaround consists in using a systemd service like this one:

[Unit]
Description=sshfs
Documentation=https://github.com/pschmitt/docker-sshfs
After=docker.service
Requires=docker.service

[Service]
WorkingDirectory=/srv/sshfs
Environment=MOUNTPOINT=/mnt/ntn
TimeoutStartSec=0
Restart=always
RestartSec=10
ExecStartPre=-/usr/bin/umount -fl ${MOUNTPOINT}
ExecStart=/opt/bin/docker-compose up
ExecStop=/opt/bin/docker-compose down
ExecStopPost=-/usr/bin/umount -fl ${MOUNTPOINT}

[Install]
WantedBy=multi-user.target