Bobcares

Rclone docker | Explained

by | Aug 23, 2022

Getting the most out of Docker support services we will look deeper into Rclone docker access tools and the command-line interface article. Bobcares will help you with detailed notes and solutions about Rclone and the other docker services.

 

 

Rclone docker Overview

 

Rclone is a function to synchronize the files and directories to and from different cloud storage providers. Usually, the Rclone maintains a docker image and these images are auto-built by the docker hub from the Rclone source based on a minimal Alpine Linux image.

 

Rclone docker

 
$ docker pull rclone/rclone:latest
latest: Pulling from rclone/rclone
Digest: sha256:0e0ced72671989bb837fea8e88578b3fc48371aa45d209663683e24cfdaa0e11
...
$ docker run --rm rclone/rclone:latest version
rclone v1.49.1
- os/arch: linux/amd64
- go version: go1.12.9
 

The given”:latest “tag will always point you to the latest stable release. You can use the”:beta “tag to get the latest build from master. Some of the version tags used are:1.49.1, :1.49 or:1.

 

Script installation

 

You can now install a Rclone on Linux/macOS/BSD, simply run the following command on your OS systems:

sudo -v ; curl https://rclone.org/install.sh | sudo bash

For beta function installation, you can go through the command:

sudo -v ; curl https://rclone.org/install.sh | sudo bash -s beta

The script checks the version of Rclone installed first and if the version is already present then it won’t re-install if not required.

 

There are a further few command line options to consider when starting a Rclone Docker from the Rclone image.

 
  • You need to mount the host Rclone config directory ” /config/rclone” in the Docker container. Additionally need to mount a host data directory i.e:  /data into the Docker container.
 
  • By default, the Rclone binary inside a Docker container runs with UID=0 which is meant to be root. As the result, all files created by the run module will have UID=0. If the config and data files are shown as non-root UID: GID then you further need to pass them on to the container start command line.
 
  • To access the RC interface either via the API or through the Web UI, need to set the --rc-addr to :5572 in order to connect from the outside container.
 
  • It is achievable to use rclone mount inside a userspace Docker container, and disclose the resulting fuse mount to the host. The exact docker run function might vary slightly between hosts. Further, you also need to mount the host /etc/passwd and /etc/group for the fuse to work within the container.
 

Here are a few sample commands that have been tested on an Ubuntu 18.04.3 host:

 
# config on host at ~/.config/rclone/rclone.conf
# data on host at ~/data

# make sure the config is ok by listing the remotes
docker run --rm \
    --volume ~/.config/rclone:/config/rclone \
    --volume ~/data:/data:shared \
    --user $(id -u):$(id -g) \
    rclone/rclone \
    listremotes

# perform mount inside Docker container, expose result to host
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 &
ls ~/data/mount
kill %1
 

Container Usage

 

This container usage will Interactively Create the Rclone docker configuration. Have a further look at the few examples provided:

[gdrive]
type = drive
client_id = 9812619862124-kjsadfkjasdflkjashdfkljashfkadjh.apps.googleusercontent.com
client_secret = KaJadHasdGAqafhKJUoakaGs
scope = drive
hdlkahsdlkhiuhgsiKJHSA_jkasdkjhaskjha_qe","expiry":"2018-06-14T10:13:20.424623462Z"}
team_drive = 0AaskdjhasKJGaskjdh

[gcache]
type = cache
remote = gdrive:
chunk_size = 5M
info_age = 1d
chunk_total_size = 1G

[gcache-crypt]
type = crypt
remote = gcache:
filename_encryption = standard
directory_name_encryption = true
password = lakldhfkuhaehadf7hkajdfhl29hrkljhasd9hDFKHASEDFMN.O3RNDLF8ADFLK3LIHslhD97HFADONLKLNkjHkljhlkjhfknadofadflkjqlkasd
password2 = adlkfhadflakhdf98had87hih&HKjhaslhsadkjgo8gi7KJlkjglgfG&aslkdhlkjgkljGLKJGSADkjhlkhasdlkhasd

[gdrive-crypt]
type = crypt
remote = gdrive:
filename_encryption = standard
directory_name_encryption = true
password = lakldhfkuhaehadf7hkajdfhl29hrkljhasd9hDFKHASEDFMN.O3RNDLF8ADFLK3LIHslhD97HFADONLKLNkjHkljhlkjhfknadofadflkjqlkasd
password2 = adlkfhadflakhdf98had87hih&HKjhaslhsadkjgo8gi7KJlkjglgfG&aslkdhlkjgkljGLKJGSADkjhlkhasdlkhasd
 

Consequently, Mount a remote drive

 
docker run --privileged \
    -v $(pwd)/config:/config \
    -v $(pwd)/mnt:/mnt:shared \
    --env CONFIG="--config /config/rclone.conf" \
    --env SUBCMD="mount" \
    --env PARAMS="--allow-other --allow-non-empty gcache-crypt: /mnt/" lucashalbert/rclone
 

Now copy the files from the local system to remote

 
docker run --privileged \
    -v $(pwd)/config:/config \
    -v $(pwd)/mnt:/mnt:shared \
    --env CONFIG="--config /config/rclone.conf" \
    --env SUBCMD="copy" \
    --env PARAMS="-v /mnt/Pictures gdrive-crypt:/Pictures"
 

Finally, access to the SSH while the Rclone container is running.

 
docker exec -it rclone sh
 

Environment Variables / Parameters

 
Variable Example Description
SUBCMD mount Rclone subcommand (see subcommands section of Rclone documentation)
CONFIG –config /config/rclone.conf Location of the Rclone configuration file
PARAMS –allow-others –allow-non-empty Options to be passed to rclone
 

Conclusion:

 

The Rclone tool is highly useful for keeping the directories synced and for migrating data between the storage platforms. This is a Go program that comes as a single binary file, helpful for Rclone daily sync and also used for scheduling a job.

 

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF