Bobcares

Rclone docker | Explained

PDF Header PDF Footer

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 *

Get featured on the Bobcares blog and share your expertise with a global tech audience.

WRITE FOR US
Docker Support

Spend time on your business, not on your servers.

Managing a server is time consuming. Whether you are an expert or a newbie, that is time you could use to focus on your product or service. Leave your server management to us, and use that time to focus on the growth and success of your business.

TALK TO US Or click here to learn more.

Speed issues driving customers away?
We’ve got your back!