Install rclone in Tomcat 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/scripts
&& mkdir /opt/externalemails
&& chmod a+x /tmp/install.sh
&& apt-get update && apt-get upgrade -y
&& apt-get install --no-install-recommends apt-utils -y
&& apt-get install fuse exfat-fuse exfat-utils -y
&& /tmp/install.sh
&& mkdir /root/.config
&& mkdir /root/.config/rclone
&& cp -r webapps.dist/* webapps/
&& mv /tmp/tomcat-users.xml /usr/local/tomcat/conf/tomcat-users.xml
&& mv /tmp/context.xml /usr/local/tomcat/conf/context.xml
&& mv /tmp/server.xml /usr/local/tomcat/conf/server.xml
&& mv /tmp/META-INF/context.xml /usr/local/tomcat/webapps/manager/META-INF/context.xml
&& mv /tmp/MikiFax.war /usr/local/tomcat/webapps/MikiFax.war
&& mv /tmp/flushAttachmentsFolder.sh /opt/scripts/flushAttachmentsFolder.sh
&& chmod a+x /opt/scripts/flushAttachmentsFolder.sh
&& mv /tmp/rclone.conf /root/.config/rclone/rclone.conf
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
;

EXPOSE 8080
CMD [“catalina.sh”, “run”]

and these are the logs when I run the build command (docker build -t my-test:1.0 .):

Sending build context to Docker daemon 4.559MB
Step 1/5 : FROM tomcat:jdk8
—> 27cd0f2670df
Step 2/5 : COPY ./files /tmp/
—> 032241e9c59a
Step 3/5 : RUN set -x && mkdir /opt/scripts && mkdir /opt/externalemails && chmod a+x /tmp/install.sh && apt-get update && apt-get upgrade -y && apt-get install --no-install-recommends apt-utils -y && apt-get install fuse exfat-fuse exfat-utils -y && /tmp/install.sh && mkdir /root/.config && mkdir /root/.config/rclone && cp -r webapps.dist/* webapps/ && mv /tmp/tomcat-users.xml /usr/local/tomcat/conf/tomcat-users.xml && mv /tmp/context.xml /usr/local/tomcat/conf/context.xml && mv /tmp/server.xml /usr/local/tomcat/conf/server.xml && mv /tmp/META-INF/context.xml /usr/local/tomcat/webapps/manager/META-INF/context.xml && mv /tmp/MikiFax.war /usr/local/tomcat/webapps/MikiFax.war && mv /tmp/flushAttachmentsFolder.sh /opt/scripts/flushAttachmentsFolder.sh && chmod a+x /opt/scripts/flushAttachmentsFolder.sh && mv /tmp/rclone.conf /root/.config/rclone/rclone.conf && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ;
—> Running in 8490a51af9e3
+ mkdir /opt/scripts
+ mkdir /opt/externalemails
+ chmod a+x /tmp/install.sh
+ apt-get update
Get:1 Index of /debian-security buster/updates InRelease [65.4 kB]
Get:2 Index of /debian buster InRelease [122 kB]
Get:3 Index of /debian buster-updates InRelease [51.9 kB]
Get:4 Index of /debian-security buster/updates/main amd64 Packages [268 kB]
Get:5 Index of /debian buster/main amd64 Packages [7907 kB]
Get:6 Index of /debian buster-updates/main amd64 Packages [9504 B]
Fetched 8423 kB in 6s (1339 kB/s)
Reading package lists…
+ apt-get upgrade -y
Reading package lists…
Building dependency tree…
Reading state information…
Calculating upgrade…
The following packages will be upgraded:
libldap-2.4-2 libldap-common libssl1.1 libsvn1 libzstd1 openssl subversion
7 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 5344 kB of archives.
After this operation, 4096 B disk space will be freed.
Get:1 Index of /debian-security buster/updates/main amd64 libzstd1 amd64 1.3.8+dfsg-3+deb10u2 [237 kB]
Get:2 Index of /debian-security buster/updates/main amd64 libssl1.1 amd64 1.1.1d-0+deb10u5 [1539 kB]
Get:3 Index of /debian-security buster/updates/main amd64 libldap-common all 2.4.47+dfsg-3+deb10u6 [90.0 kB]
Get:4 Index of /debian-security buster/updates/main amd64 libldap-2.4-2 amd64 2.4.47+dfsg-3+deb10u6 [224 kB]
Get:5 Index of /debian-security buster/updates/main amd64 subversion amd64 1.10.4-1+deb10u2 [1008 kB]
Get:6 Index of /debian-security buster/updates/main amd64 libsvn1 amd64 1.10.4-1+deb10u2 [1403 kB]
Get:7 Index of /debian-security buster/updates/main amd64 openssl amd64 1.1.1d-0+deb10u5 [844 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 5344 kB in 1s (4547 kB/s)
(Reading database … 12572 files and directories currently installed.)
Preparing to unpack …/libzstd1_1.3.8+dfsg-3+deb10u2_amd64.deb …
Unpacking libzstd1:amd64 (1.3.8+dfsg-3+deb10u2) over (1.3.8+dfsg-3) …
Setting up libzstd1:amd64 (1.3.8+dfsg-3+deb10u2) …
(Reading database … 12572 files and directories currently installed.)
Preparing to unpack …/0-libssl1.1_1.1.1d-0+deb10u5_amd64.deb …
Unpacking libssl1.1:amd64 (1.1.1d-0+deb10u5) over (1.1.1d-0+deb10u4) …
Preparing to unpack …/1-libldap-common_2.4.47+dfsg-3+deb10u6_all.deb …
Unpacking libldap-common (2.4.47+dfsg-3+deb10u6) over (2.4.47+dfsg-3+deb10u5) …
Preparing to unpack …/2-libldap-2.4-2_2.4.47+dfsg-3+deb10u6_amd64.deb …
Unpacking libldap-2.4-2:amd64 (2.4.47+dfsg-3+deb10u6) over (2.4.47+dfsg-3+deb10u5) …
Preparing to unpack …/3-subversion_1.10.4-1+deb10u2_amd64.deb …
Unpacking subversion (1.10.4-1+deb10u2) over (1.10.4-1+deb10u1) …
Preparing to unpack …/4-libsvn1_1.10.4-1+deb10u2_amd64.deb …
Unpacking libsvn1:amd64 (1.10.4-1+deb10u2) over (1.10.4-1+deb10u1) …
Preparing to unpack …/5-openssl_1.1.1d-0+deb10u5_amd64.deb …
Unpacking openssl (1.1.1d-0+deb10u5) over (1.1.1d-0+deb10u4) …
Setting up libssl1.1:amd64 (1.1.1d-0+deb10u5) …
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
Setting up libldap-common (2.4.47+dfsg-3+deb10u6) …
Setting up libsvn1:amd64 (1.10.4-1+deb10u2) …
Setting up openssl (1.1.1d-0+deb10u5) …
Setting up subversion (1.10.4-1+deb10u2) …
Setting up libldap-2.4-2:amd64 (2.4.47+dfsg-3+deb10u6) …
Processing triggers for libc-bin (2.28-10) …
+ apt-get install --no-install-recommends apt-utils -y
Reading package lists…
Building dependency tree…
Reading state information…
The following additional packages will be installed:
libapt-inst2.0
The following NEW packages will be installed:
apt-utils libapt-inst2.0
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 625 kB of archives.
After this operation, 1650 kB of additional disk space will be used.
Get:1 Index of /debian buster/main amd64 libapt-inst2.0 amd64 1.8.2.2 [204 kB]
Get:2 Index of /debian buster/main amd64 apt-utils amd64 1.8.2.2 [421 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 625 kB in 0s (4497 kB/s)
Selecting previously unselected package libapt-inst2.0:amd64.
(Reading database … 12572 files and directories currently installed.)
Preparing to unpack …/libapt-inst2.0_1.8.2.2_amd64.deb …
Unpacking libapt-inst2.0:amd64 (1.8.2.2) …
Selecting previously unselected package apt-utils.
Preparing to unpack …/apt-utils_1.8.2.2_amd64.deb …
Unpacking apt-utils (1.8.2.2) …
Setting up libapt-inst2.0:amd64 (1.8.2.2) …
Setting up apt-utils (1.8.2.2) …
Processing triggers for libc-bin (2.28-10) …
+ 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 0 not upgraded.
Need to get 275 kB of archives.
After this operation, 808 kB of additional disk space will be used.
Get:1 Index of /debian buster/main amd64 libfuse2 amd64 2.9.9-1+deb10u1 [128 kB]
Get:2 Index of /debian buster/main amd64 fuse amd64 2.9.9-1+deb10u1 [72.3 kB]
Get:3 Index of /debian buster/main amd64 exfat-fuse amd64 1.3.0-1 [29.4 kB]
Get:4 Index of /debian buster/main amd64 exfat-utils amd64 1.3.0-1 [45.2 kB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin:
Fetched 275 kB in 0s (2161 kB/s)
Selecting previously unselected package libfuse2:amd64.
(Reading database … 12702 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) …
+ /tmp/install.sh
** % Total % Received % Xferd Average Speed Time Time Time Current**
** Dload Upload Total Spent Left Speed**
100 15 100 15 0 0 85 0 --:–:-- --:–:-- --:–:-- 85
** % Total % Received % Xferd Average Speed Time Time Time Current**
** Dload Upload Total Spent Left Speed**
100 13.4M 100 13.4M 0 0 5742k 0 0:00:02 0:00:02 --:–:-- 5742k
Archive: rclone-current-linux-amd64.zip
creating: tmp_unzip_dir_for_rclone/rclone-v1.54.1-linux-amd64/
inflating: tmp_unzip_dir_for_rclone/rclone-v1.54.1-linux-amd64/git-log.txt [text]
inflating: tmp_unzip_dir_for_rclone/rclone-v1.54.1-linux-amd64/rclone.1 [text]
inflating: tmp_unzip_dir_for_rclone/rclone-v1.54.1-linux-amd64/rclone [binary]
inflating: tmp_unzip_dir_for_rclone/rclone-v1.54.1-linux-amd64/README.html [text]
inflating: tmp_unzip_dir_for_rclone/rclone-v1.54.1-linux-amd64/README.txt [text]
mandb not found. The rclone man docs will not be installed.

rclone v1.54.1 has successfully installed.
Now run “rclone config” for setup. Check Documentation for more details.

+ mkdir /root/.config
+ mkdir /root/.config/rclone
+ cp -r webapps.dist/ROOT webapps.dist/docs webapps.dist/examples webapps.dist/host-manager webapps.dist/manager webapps/
+ mv /tmp/tomcat-users.xml /usr/local/tomcat/conf/tomcat-users.xml
+ mv /tmp/context.xml /usr/local/tomcat/conf/context.xml
+ mv /tmp/server.xml /usr/local/tomcat/conf/server.xml
+ mv /tmp/META-INF/context.xml /usr/local/tomcat/webapps/manager/META-INF/context.xml
+ mv /tmp/MikiFax.war /usr/local/tomcat/webapps/MikiFax.war
+ mv /tmp/flushAttachmentsFolder.sh /opt/scripts/flushAttachmentsFolder.sh
+ chmod a+x /opt/scripts/flushAttachmentsFolder.sh
+ mv /tmp/rclone.conf /root/.config/rclone/rclone.conf
+ apt-get clean
+ rm -rf /var/lib/apt/lists/auxfiles /var/lib/apt/lists/deb.debian.org_debian_dists_buster-updates_InRelease /var/lib/apt/lists/deb.debian.org_debian_dists_buster-updates_main_binary-amd64_Packages.lz4 /var/lib/apt/lists/deb.debian.org_debian_dists_buster_InRelease /var/lib/apt/lists/deb.debian.org_debian_dists_buster_main_binary-amd64_Packages.lz4 /var/lib/apt/lists/lock /var/lib/apt/lists/partial /var/lib/apt/lists/security.debian.org_debian-security_dists_buster_updates_InRelease /var/lib/apt/lists/security.debian.org_debian-security_dists_buster_updates_main_binary-amd64_Packages.lz4 /tmp/META-INF /tmp/hsperfdata_root /tmp/install.sh /tmp/rclone.service /tmp/tmp.nqGQEC1BJW /var/tmp/*
Removing intermediate container 8490a51af9e3
—> e37e87982b06
Step 4/5 : EXPOSE 8080
—> Running in a326c9b79b21
Removing intermediate container a326c9b79b21
—> 19ed9c633e50
Step 5/5 : CMD [“catalina.sh”, “run”]
—> Running in c6d181fc3d9a
Removing intermediate container c6d181fc3d9a
—> 4dad4a134fbe
Successfully built 4dad4a134fbe
Successfully tagged f2x-test:1.0

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,
I have an update.
I can run correctly the container with this command:

docker run -d -p 80:8080 --restart unless-stopped --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined --name f2xtest f2x-test:1.0

And If I enter in the container and run the command:

rclone mount gdrive: /opt/externalemails/

I can mount the gdrive into my container.

I have the last question: how can run the command into Dockerfile?
In my VM I run it as a services, how can add it on the Dockerfile?

Thanks a lot for your support.

Hi I solved in this way:

FROM tomcat:jdk8

COPY ./files /tmp/

RUN set -x
&& mkdir /opt/scripts
&& mkdir /opt/externalemails
&& apt-get update && apt-get upgrade -y
&& apt-get install --no-install-recommends apt-utils -y
&& apt-get install fuse exfat-fuse exfat-utils -y
&& chmod a+x /tmp/rclone/install.sh
&& /tmp/rclone/install.sh
&& mkdir /root/.config
&& mkdir /root/.config/rclone
&& cp -r webapps.dist/* webapps/
&& mv /tmp/tomcat/tomcat-users.xml /usr/local/tomcat/conf/tomcat-users.xml
&& mv /tmp/tomcat/context.xml /usr/local/tomcat/conf/context.xml
&& mv /tmp/tomcat/server.xml /usr/local/tomcat/conf/server.xml
&& mv /tmp/tomcat/META-INF/context.xml /usr/local/tomcat/webapps/manager/META-INF/context.xml
&& mv /tmp/tomcat/MikiFax.war /usr/local/tomcat/webapps/MikiFax.war
&& mv /tmp/services/flushAttachmentsFolder.sh /opt/scripts/flushAttachmentsFolder.sh
&& chmod a+x /opt/scripts/flushAttachmentsFolder.sh
&& mv /tmp/services/start-services.sh /opt/scripts/start-services.sh
&& chmod a+x /opt/scripts/start-services.sh
&& mv /tmp/rclone/rclone.conf /root/.config/rclone/rclone.conf
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
;

EXPOSE 8080

CMD [“/opt/scripts/start-services.sh”, “/bin/bash”]

and after I build the image with the command:

docker build -t my-app:1.0 .

and run container with the command:

docker run -d -p 80:8080 --restart unless-stopped --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined --name my-app my-app:1.0 .