Configure rclone into Docker container

Hi all,
I'm using rclone in my linux web server as shared storage for any files that I read from the web application. I configured it with Google Drive without problem.

Now I'm trying to convert my VM into a container, and I started from the Tomcat container, and I installed the rclone using Dockerfile below:

VM:

rclone:
rclone v1.53.3
- os/arch: linux/amd64
- go version: go1.15.5
OS:
Oracle Linux 8.3

Docker Container:

rclone:
rclone v1.54.1
- os/arch: linux/amd64
- go version: go1.15.8
OS:
Linux debian 10.8

Dovckerfile:

FROM tomcat:jdk8

COPY ./files /tmp/

RUN set -x
&& mkdir /opt/googledrive-rclone
&& chmod a+x /tmp/install.sh
&& /tmp/install.sh
&& mkdir /root/.config
&& mkdir /root/.config/rclone
&& mv /tmp/rclone.conf /root/.config/rclone/rclone.conf
;

EXPOSE 8080
CMD ["catalina.sh", "run"]

Now I'm testing the container, I'm running into the container this mount command:

rclone mount gdrive: /opt/googledrive-rclone/

I receive this error:

root@c18839c1276c:/usr/local/tomcat# rclone mount gdrive: /opt/externalemails/
2021/03/17 15:12:54 Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH

Thanks for the update.

Hi, welcome to the forum!

Do you have package fuse installed in your container? See also rclone's official Dockerfile.

1 Like

Hi Albertony,
thank you for your reply.

I think it wasn't installed, I'm trying to install it.

I tried to use the offical Docker container for rclone, but I can't start it.
Did you use it?

Thanks for your support.
Marco

Good, let me know how if it works out!

No, have not tried it myself.

1 Like

I installed fuse with this command:

+ apt-get install fuse exfat-fuse exfat-utils -y
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
libfuse2
The following NEW packages will be installed:
exfat-fuse exfat-utils fuse libfuse2
0 upgraded, 4 newly installed, 0 to remove and 7 not upgraded.
Need to get 275 kB of archives.
After this operation, 808 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian buster/main amd64 libfuse2 amd64 2.9.9-1+deb10u1 [128 kB]
Get:2 http://deb.debian.org/debian buster/main amd64 fuse amd64 2.9.9-1+deb10u1 [72.3 kB]
Get:3 http://deb.debian.org/debian buster/main amd64 exfat-fuse amd64 1.3.0-1 [29.4 kB]
Get:4 http://deb.debian.org/debian buster/main amd64 exfat-utils amd64 1.3.0-1 [45.2 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 275 kB in 0s (2716 kB/s)
Selecting previously unselected package libfuse2:amd64.
(Reading database ... 12572 files and directories currently installed.)
Preparing to unpack .../libfuse2_2.9.9-1+deb10u1_amd64.deb ...
Unpacking libfuse2:amd64 (2.9.9-1+deb10u1) ...
Selecting previously unselected package fuse.
Preparing to unpack .../fuse_2.9.9-1+deb10u1_amd64.deb ...
Unpacking fuse (2.9.9-1+deb10u1) ...
Selecting previously unselected package exfat-fuse.
Preparing to unpack .../exfat-fuse_1.3.0-1_amd64.deb ...
Unpacking exfat-fuse (1.3.0-1) ...
Selecting previously unselected package exfat-utils.
Preparing to unpack .../exfat-utils_1.3.0-1_amd64.deb ...
Unpacking exfat-utils (1.3.0-1) ...
Setting up libfuse2:amd64 (2.9.9-1+deb10u1) ...
Setting up exfat-utils (1.3.0-1) ...
Setting up fuse (2.9.9-1+deb10u1) ...
Setting up exfat-fuse (1.3.0-1) ...
Processing triggers for libc-bin (2.28-10) ...

but now I receive this error:

root@796b8aacd8b1:/opt/externalemails# rclone mount gdrive: /opt/externalemails/
2021/03/17 15:42:26 mount helper error: fusermount: fuse device not found, try 'modprobe fuse' first
2021/03/17 15:42:26 Fatal error: failed to mount FUSE fs: fusermount: exit status 1

What is the host machine?

Does it have FUSE support built into its kernel?

How can check if FUSE support built into its kernel?

The docker image is: tomcat:jdk8 based on Debian 10.8 with kernel
5.4.17-2036.104.4.el8uek.x86_64

You need to check the host not the docker image.

Also check the installing with docker section on the website - are you using these magic flags

mkdir -p ~/data/mount
docker run --rm \
    --volume ~/.config/rclone:/config/rclone \
    --volume ~/data:/data:shared \
    --user $(id -u):$(id -g) \
    --volume /etc/passwd:/etc/passwd:ro --volume /etc/group:/etc/group:ro \
    --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined \
    rclone/rclone \
    mount dropbox:Photos /data/mount &

I suspect that the --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined line is the one you need to fix this problem.

Thank you for your reply.

rclone works correctly on my host, the problem is that it must run into the docker container.
I would create a custom image with Tomcat and rclone in the same image.
Is it possible?

Sure.

Did you try adding

--device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined

to your docker run command.

1 Like

Hi,
thanks you so much for your reply, it works.

I have the last question: how can run the command

rclone mount gdrive: /opt/externalemails/

inside the container?
In my VM I run it as a services, how can add it on the Dockerfile?

Thanks a lot for your support.

Great!

Parameters you add to your docker command line will get passed to rclone, so something like this, assuming /opt/externalemails is an empty folder.

docker run --rm \
    --volume ~/.config/rclone:/config/rclone \
    --volume /opt/externalemails:/data:shared \
    --user $(id -u):$(id -g) \
    --volume /etc/passwd:/etc/passwd:ro --volume /etc/group:/etc/group:ro \
    --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined \
    rclone/rclone \
    mount gdrive: /data
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.