Rclone Docker Plugin
Date:
[]
Categories:
[Tech]
Tags:
[Linux],
[Container],
[Docker]
rclone
is a powerful command-line program that helps you manage files hosted on cloud storages. It supports a wide range of cloud storage providers and can be easily integrated into Docker containers using the rclone
Docker plugin.
This blog is a simplified documentation for reference. Official documentation is available here.
Prerequisites
Before we dive in, ensure you have the following:
- Docker Runtime v1.9: Already installed and configured on your system. Older versions might not support volume plugins.
- FUSE driver: This is required by
rclone
to mount remote storage as a local filesystem. (sudo apt-get -y install fuse
)
Step 1: Install the rclone
Managed Plugin
First, you need to create directories used by the plugin.
sudo mkdir -p /var/lib/docker-plugins/rclone/config
sudo mkdir -p /var/lib/docker-plugins/rclone/cache
Then, install the rclone
Docker Volume Plugin by pulling the plugin image from Docker Hub.
docker plugin install rclone/docker-volume-rclone:amd64 --grant-all-permissions --alias rclone
To verify that the plugin has been installed successfully, list the installed Docker plugins.
docker plugin list
You should see rclone/rclone
in the list of installed plugins.
The managed plugin is a special container running in a namespace separate from normal Docker containers. Inside it runs the rclone serve docker
command.
The --grant-all-permissions
flag ensures that the plugin has the necessary permissions to function correctly.
As of this writing, the following plugin architectures are currently available:
- amd64
- arm64
- arm-v7
Step 2: Configure the Plugin
Next, you need to configure rclone
to connect to your cloud storage provider. This involves creating a configuration file.
1. Create a Configuration File in the Plugin Directory
You need to manually create the rclone.conf
file inside the plugin directory.
touch /var/lib/docker-plugins/rclone/config/rclone.conf
2. Add Remotes to Your rclone
Configuration
Run rclone config
with the --config
path set to the rclone.conf
file you just created.
# dont forget the sudo!
sudo rclone --config=/var/lib/docker-plugins/rclone/config/rclone.conf config
Notice that there are two config
parameters: one is a flag (--config
), and the other is a command (config
). Add your cloud storage configuration as you normally would.
Step 3: Use the Plugin in a Docker Container
Now that rclone
is configured, you can create a volume and set rclone
as the driver.
docker volume create <volume_name> -d rclone -o remote=<remote_name>
In this command:
-d rclone
: Setsrclone
as the driver.-o remote=<remote_name>
: Mountsremote_name
at the volume root.
Step 4: Automate with Docker Compose (Optional)
If you prefer using Docker Compose, you can create a docker-compose.yml
file to automate the process:
volumes:
remote_name_folder:
driver: rclone
driver_opts:
remote: "remote_name:remote_folder"
services:
app:
image: debian
tty: true
stdin_open: true
volumes:
- remote_name_folder:/data
command: ls -lah /data
Then run docker compose up
to start the service.
Conclusion
Setting up the rclone
Managed Docker plugin on a Debian Linux system is a straightforward process that can significantly enhance your cloud storage management capabilities. By following these steps, you can easily integrate rclone
into your Docker workflow and leverage its powerful features.