github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/docs/content/commands/rclone_serve_docker.md (about) 1 --- 2 title: "rclone serve docker" 3 description: "Serve any remote on docker's volume plugin API." 4 slug: rclone_serve_docker 5 url: /commands/rclone_serve_docker/ 6 groups: Filter 7 versionIntroduced: v1.56 8 # autogenerated - DO NOT EDIT, instead edit the source code in cmd/serve/docker/ and as part of making a release run "make commanddocs" 9 --- 10 # rclone serve docker 11 12 Serve any remote on docker's volume plugin API. 13 14 ## Synopsis 15 16 This command implements the Docker volume plugin API allowing docker to use 17 rclone as a data storage mechanism for various cloud providers. 18 rclone provides [docker volume plugin](/docker) based on it. 19 20 To create a docker plugin, one must create a Unix or TCP socket that Docker 21 will look for when you use the plugin and then it listens for commands from 22 docker daemon and runs the corresponding code when necessary. 23 Docker plugins can run as a managed plugin under control of the docker daemon 24 or as an independent native service. For testing, you can just run it directly 25 from the command line, for example: 26 ``` 27 sudo rclone serve docker --base-dir /tmp/rclone-volumes --socket-addr localhost:8787 -vv 28 ``` 29 30 Running `rclone serve docker` will create the said socket, listening for 31 commands from Docker to create the necessary Volumes. Normally you need not 32 give the `--socket-addr` flag. The API will listen on the unix domain socket 33 at `/run/docker/plugins/rclone.sock`. In the example above rclone will create 34 a TCP socket and a small file `/etc/docker/plugins/rclone.spec` containing 35 the socket address. We use `sudo` because both paths are writeable only by 36 the root user. 37 38 If you later decide to change listening socket, the docker daemon must be 39 restarted to reconnect to `/run/docker/plugins/rclone.sock` 40 or parse new `/etc/docker/plugins/rclone.spec`. Until you restart, any 41 volume related docker commands will timeout trying to access the old socket. 42 Running directly is supported on **Linux only**, not on Windows or MacOS. 43 This is not a problem with managed plugin mode described in details 44 in the [full documentation](https://rclone.org/docker). 45 46 The command will create volume mounts under the path given by `--base-dir` 47 (by default `/var/lib/docker-volumes/rclone` available only to root) 48 and maintain the JSON formatted file `docker-plugin.state` in the rclone cache 49 directory with book-keeping records of created and mounted volumes. 50 51 All mount and VFS options are submitted by the docker daemon via API, but 52 you can also provide defaults on the command line as well as set path to the 53 config file and cache directory or adjust logging verbosity. 54 55 ## VFS - Virtual File System 56 57 This command uses the VFS layer. This adapts the cloud storage objects 58 that rclone uses into something which looks much more like a disk 59 filing system. 60 61 Cloud storage objects have lots of properties which aren't like disk 62 files - you can't extend them or write to the middle of them, so the 63 VFS layer has to deal with that. Because there is no one right way of 64 doing this there are various options explained below. 65 66 The VFS layer also implements a directory cache - this caches info 67 about files and directories (but not the data) in memory. 68 69 ## VFS Directory Cache 70 71 Using the `--dir-cache-time` flag, you can control how long a 72 directory should be considered up to date and not refreshed from the 73 backend. Changes made through the VFS will appear immediately or 74 invalidate the cache. 75 76 --dir-cache-time duration Time to cache directory entries for (default 5m0s) 77 --poll-interval duration Time to wait between polling for changes. Must be smaller than dir-cache-time. Only on supported remotes. Set to 0 to disable (default 1m0s) 78 79 However, changes made directly on the cloud storage by the web 80 interface or a different copy of rclone will only be picked up once 81 the directory cache expires if the backend configured does not support 82 polling for changes. If the backend supports polling, changes will be 83 picked up within the polling interval. 84 85 You can send a `SIGHUP` signal to rclone for it to flush all 86 directory caches, regardless of how old they are. Assuming only one 87 rclone instance is running, you can reset the cache like this: 88 89 kill -SIGHUP $(pidof rclone) 90 91 If you configure rclone with a [remote control](/rc) then you can use 92 rclone rc to flush the whole directory cache: 93 94 rclone rc vfs/forget 95 96 Or individual files or directories: 97 98 rclone rc vfs/forget file=path/to/file dir=path/to/dir 99 100 ## VFS File Buffering 101 102 The `--buffer-size` flag determines the amount of memory, 103 that will be used to buffer data in advance. 104 105 Each open file will try to keep the specified amount of data in memory 106 at all times. The buffered data is bound to one open file and won't be 107 shared. 108 109 This flag is a upper limit for the used memory per open file. The 110 buffer will only use memory for data that is downloaded but not not 111 yet read. If the buffer is empty, only a small amount of memory will 112 be used. 113 114 The maximum memory used by rclone for buffering can be up to 115 `--buffer-size * open files`. 116 117 ## VFS File Caching 118 119 These flags control the VFS file caching options. File caching is 120 necessary to make the VFS layer appear compatible with a normal file 121 system. It can be disabled at the cost of some compatibility. 122 123 For example you'll need to enable VFS caching if you want to read and 124 write simultaneously to a file. See below for more details. 125 126 Note that the VFS cache is separate from the cache backend and you may 127 find that you need one or the other or both. 128 129 --cache-dir string Directory rclone will use for caching. 130 --vfs-cache-mode CacheMode Cache mode off|minimal|writes|full (default off) 131 --vfs-cache-max-age duration Max time since last access of objects in the cache (default 1h0m0s) 132 --vfs-cache-max-size SizeSuffix Max total size of objects in the cache (default off) 133 --vfs-cache-min-free-space SizeSuffix Target minimum free space on the disk containing the cache (default off) 134 --vfs-cache-poll-interval duration Interval to poll the cache for stale objects (default 1m0s) 135 --vfs-write-back duration Time to writeback files after last use when using cache (default 5s) 136 137 If run with `-vv` rclone will print the location of the file cache. The 138 files are stored in the user cache file area which is OS dependent but 139 can be controlled with `--cache-dir` or setting the appropriate 140 environment variable. 141 142 The cache has 4 different modes selected by `--vfs-cache-mode`. 143 The higher the cache mode the more compatible rclone becomes at the 144 cost of using disk space. 145 146 Note that files are written back to the remote only when they are 147 closed and if they haven't been accessed for `--vfs-write-back` 148 seconds. If rclone is quit or dies with files that haven't been 149 uploaded, these will be uploaded next time rclone is run with the same 150 flags. 151 152 If using `--vfs-cache-max-size` or `--vfs-cache-min-free-size` note 153 that the cache may exceed these quotas for two reasons. Firstly 154 because it is only checked every `--vfs-cache-poll-interval`. Secondly 155 because open files cannot be evicted from the cache. When 156 `--vfs-cache-max-size` or `--vfs-cache-min-free-size` is exceeded, 157 rclone will attempt to evict the least accessed files from the cache 158 first. rclone will start with files that haven't been accessed for the 159 longest. This cache flushing strategy is efficient and more relevant 160 files are likely to remain cached. 161 162 The `--vfs-cache-max-age` will evict files from the cache 163 after the set time since last access has passed. The default value of 164 1 hour will start evicting files from cache that haven't been accessed 165 for 1 hour. When a cached file is accessed the 1 hour timer is reset to 0 166 and will wait for 1 more hour before evicting. Specify the time with 167 standard notation, s, m, h, d, w . 168 169 You **should not** run two copies of rclone using the same VFS cache 170 with the same or overlapping remotes if using `--vfs-cache-mode > off`. 171 This can potentially cause data corruption if you do. You can work 172 around this by giving each rclone its own cache hierarchy with 173 `--cache-dir`. You don't need to worry about this if the remotes in 174 use don't overlap. 175 176 ### --vfs-cache-mode off 177 178 In this mode (the default) the cache will read directly from the remote and write 179 directly to the remote without caching anything on disk. 180 181 This will mean some operations are not possible 182 183 * Files can't be opened for both read AND write 184 * Files opened for write can't be seeked 185 * Existing files opened for write must have O_TRUNC set 186 * Files open for read with O_TRUNC will be opened write only 187 * Files open for write only will behave as if O_TRUNC was supplied 188 * Open modes O_APPEND, O_TRUNC are ignored 189 * If an upload fails it can't be retried 190 191 ### --vfs-cache-mode minimal 192 193 This is very similar to "off" except that files opened for read AND 194 write will be buffered to disk. This means that files opened for 195 write will be a lot more compatible, but uses the minimal disk space. 196 197 These operations are not possible 198 199 * Files opened for write only can't be seeked 200 * Existing files opened for write must have O_TRUNC set 201 * Files opened for write only will ignore O_APPEND, O_TRUNC 202 * If an upload fails it can't be retried 203 204 ### --vfs-cache-mode writes 205 206 In this mode files opened for read only are still read directly from 207 the remote, write only and read/write files are buffered to disk 208 first. 209 210 This mode should support all normal file system operations. 211 212 If an upload fails it will be retried at exponentially increasing 213 intervals up to 1 minute. 214 215 ### --vfs-cache-mode full 216 217 In this mode all reads and writes are buffered to and from disk. When 218 data is read from the remote this is buffered to disk as well. 219 220 In this mode the files in the cache will be sparse files and rclone 221 will keep track of which bits of the files it has downloaded. 222 223 So if an application only reads the starts of each file, then rclone 224 will only buffer the start of the file. These files will appear to be 225 their full size in the cache, but they will be sparse files with only 226 the data that has been downloaded present in them. 227 228 This mode should support all normal file system operations and is 229 otherwise identical to `--vfs-cache-mode` writes. 230 231 When reading a file rclone will read `--buffer-size` plus 232 `--vfs-read-ahead` bytes ahead. The `--buffer-size` is buffered in memory 233 whereas the `--vfs-read-ahead` is buffered on disk. 234 235 When using this mode it is recommended that `--buffer-size` is not set 236 too large and `--vfs-read-ahead` is set large if required. 237 238 **IMPORTANT** not all file systems support sparse files. In particular 239 FAT/exFAT do not. Rclone will perform very badly if the cache 240 directory is on a filesystem which doesn't support sparse files and it 241 will log an ERROR message if one is detected. 242 243 ### Fingerprinting 244 245 Various parts of the VFS use fingerprinting to see if a local file 246 copy has changed relative to a remote file. Fingerprints are made 247 from: 248 249 - size 250 - modification time 251 - hash 252 253 where available on an object. 254 255 On some backends some of these attributes are slow to read (they take 256 an extra API call per object, or extra work per object). 257 258 For example `hash` is slow with the `local` and `sftp` backends as 259 they have to read the entire file and hash it, and `modtime` is slow 260 with the `s3`, `swift`, `ftp` and `qinqstor` backends because they 261 need to do an extra API call to fetch it. 262 263 If you use the `--vfs-fast-fingerprint` flag then rclone will not 264 include the slow operations in the fingerprint. This makes the 265 fingerprinting less accurate but much faster and will improve the 266 opening time of cached files. 267 268 If you are running a vfs cache over `local`, `s3` or `swift` backends 269 then using this flag is recommended. 270 271 Note that if you change the value of this flag, the fingerprints of 272 the files in the cache may be invalidated and the files will need to 273 be downloaded again. 274 275 ## VFS Chunked Reading 276 277 When rclone reads files from a remote it reads them in chunks. This 278 means that rather than requesting the whole file rclone reads the 279 chunk specified. This can reduce the used download quota for some 280 remotes by requesting only chunks from the remote that are actually 281 read, at the cost of an increased number of requests. 282 283 These flags control the chunking: 284 285 --vfs-read-chunk-size SizeSuffix Read the source objects in chunks (default 128M) 286 --vfs-read-chunk-size-limit SizeSuffix Max chunk doubling size (default off) 287 288 Rclone will start reading a chunk of size `--vfs-read-chunk-size`, 289 and then double the size for each read. When `--vfs-read-chunk-size-limit` is 290 specified, and greater than `--vfs-read-chunk-size`, the chunk size for each 291 open file will get doubled only until the specified value is reached. If the 292 value is "off", which is the default, the limit is disabled and the chunk size 293 will grow indefinitely. 294 295 With `--vfs-read-chunk-size 100M` and `--vfs-read-chunk-size-limit 0` 296 the following parts will be downloaded: 0-100M, 100M-200M, 200M-300M, 300M-400M and so on. 297 When `--vfs-read-chunk-size-limit 500M` is specified, the result would be 298 0-100M, 100M-300M, 300M-700M, 700M-1200M, 1200M-1700M and so on. 299 300 Setting `--vfs-read-chunk-size` to `0` or "off" disables chunked reading. 301 302 ## VFS Performance 303 304 These flags may be used to enable/disable features of the VFS for 305 performance or other reasons. See also the [chunked reading](#vfs-chunked-reading) 306 feature. 307 308 In particular S3 and Swift benefit hugely from the `--no-modtime` flag 309 (or use `--use-server-modtime` for a slightly different effect) as each 310 read of the modification time takes a transaction. 311 312 --no-checksum Don't compare checksums on up/download. 313 --no-modtime Don't read/write the modification time (can speed things up). 314 --no-seek Don't allow seeking in files. 315 --read-only Only allow read-only access. 316 317 Sometimes rclone is delivered reads or writes out of order. Rather 318 than seeking rclone will wait a short time for the in sequence read or 319 write to come in. These flags only come into effect when not using an 320 on disk cache file. 321 322 --vfs-read-wait duration Time to wait for in-sequence read before seeking (default 20ms) 323 --vfs-write-wait duration Time to wait for in-sequence write before giving error (default 1s) 324 325 When using VFS write caching (`--vfs-cache-mode` with value writes or full), 326 the global flag `--transfers` can be set to adjust the number of parallel uploads of 327 modified files from the cache (the related global flag `--checkers` has no effect on the VFS). 328 329 --transfers int Number of file transfers to run in parallel (default 4) 330 331 ## VFS Case Sensitivity 332 333 Linux file systems are case-sensitive: two files can differ only 334 by case, and the exact case must be used when opening a file. 335 336 File systems in modern Windows are case-insensitive but case-preserving: 337 although existing files can be opened using any case, the exact case used 338 to create the file is preserved and available for programs to query. 339 It is not allowed for two files in the same directory to differ only by case. 340 341 Usually file systems on macOS are case-insensitive. It is possible to make macOS 342 file systems case-sensitive but that is not the default. 343 344 The `--vfs-case-insensitive` VFS flag controls how rclone handles these 345 two cases. If its value is "false", rclone passes file names to the remote 346 as-is. If the flag is "true" (or appears without a value on the 347 command line), rclone may perform a "fixup" as explained below. 348 349 The user may specify a file name to open/delete/rename/etc with a case 350 different than what is stored on the remote. If an argument refers 351 to an existing file with exactly the same name, then the case of the existing 352 file on the disk will be used. However, if a file name with exactly the same 353 name is not found but a name differing only by case exists, rclone will 354 transparently fixup the name. This fixup happens only when an existing file 355 is requested. Case sensitivity of file names created anew by rclone is 356 controlled by the underlying remote. 357 358 Note that case sensitivity of the operating system running rclone (the target) 359 may differ from case sensitivity of a file system presented by rclone (the source). 360 The flag controls whether "fixup" is performed to satisfy the target. 361 362 If the flag is not provided on the command line, then its default value depends 363 on the operating system where rclone runs: "true" on Windows and macOS, "false" 364 otherwise. If the flag is provided without a value, then it is "true". 365 366 The `--no-unicode-normalization` flag controls whether a similar "fixup" is 367 performed for filenames that differ but are [canonically 368 equivalent](https://en.wikipedia.org/wiki/Unicode_equivalence) with respect to 369 unicode. Unicode normalization can be particularly helpful for users of macOS, 370 which prefers form NFD instead of the NFC used by most other platforms. It is 371 therefore highly recommended to keep the default of `false` on macOS, to avoid 372 encoding compatibility issues. 373 374 In the (probably unlikely) event that a directory has multiple duplicate 375 filenames after applying case and unicode normalization, the `--vfs-block-norm-dupes` 376 flag allows hiding these duplicates. This comes with a performance tradeoff, as 377 rclone will have to scan the entire directory for duplicates when listing a 378 directory. For this reason, it is recommended to leave this disabled if not 379 needed. However, macOS users may wish to consider using it, as otherwise, if a 380 remote directory contains both NFC and NFD versions of the same filename, an odd 381 situation will occur: both versions of the file will be visible in the mount, 382 and both will appear to be editable, however, editing either version will 383 actually result in only the NFD version getting edited under the hood. `--vfs-block- 384 norm-dupes` prevents this confusion by detecting this scenario, hiding the 385 duplicates, and logging an error, similar to how this is handled in `rclone 386 sync`. 387 388 ## VFS Disk Options 389 390 This flag allows you to manually set the statistics about the filing system. 391 It can be useful when those statistics cannot be read correctly automatically. 392 393 --vfs-disk-space-total-size Manually set the total disk space size (example: 256G, default: -1) 394 395 ## Alternate report of used bytes 396 397 Some backends, most notably S3, do not report the amount of bytes used. 398 If you need this information to be available when running `df` on the 399 filesystem, then pass the flag `--vfs-used-is-size` to rclone. 400 With this flag set, instead of relying on the backend to report this 401 information, rclone will scan the whole remote similar to `rclone size` 402 and compute the total used space itself. 403 404 _WARNING._ Contrary to `rclone size`, this flag ignores filters so that the 405 result is accurate. However, this is very inefficient and may cost lots of API 406 calls resulting in extra charges. Use it as a last resort and only with caching. 407 408 409 ``` 410 rclone serve docker [flags] 411 ``` 412 413 ## Options 414 415 ``` 416 --allow-non-empty Allow mounting over a non-empty directory (not supported on Windows) 417 --allow-other Allow access to other users (not supported on Windows) 418 --allow-root Allow access to root user (not supported on Windows) 419 --async-read Use asynchronous reads (not supported on Windows) (default true) 420 --attr-timeout Duration Time for which file/directory attributes are cached (default 1s) 421 --base-dir string Base directory for volumes (default "/var/lib/docker-volumes/rclone") 422 --daemon Run mount in background and exit parent process (as background output is suppressed, use --log-file with --log-format=pid,... to monitor) (not supported on Windows) 423 --daemon-timeout Duration Time limit for rclone to respond to kernel (not supported on Windows) (default 0s) 424 --daemon-wait Duration Time to wait for ready mount from daemon (maximum time on Linux, constant sleep time on OSX/BSD) (not supported on Windows) (default 1m0s) 425 --debug-fuse Debug the FUSE internals - needs -v 426 --default-permissions Makes kernel enforce access control based on the file mode (not supported on Windows) 427 --devname string Set the device name - default is remote:path 428 --dir-cache-time Duration Time to cache directory entries for (default 5m0s) 429 --dir-perms FileMode Directory permissions (default 0777) 430 --file-perms FileMode File permissions (default 0666) 431 --forget-state Skip restoring previous state 432 --fuse-flag stringArray Flags or arguments to be passed direct to libfuse/WinFsp (repeat if required) 433 --gid uint32 Override the gid field set by the filesystem (not supported on Windows) (default 1000) 434 -h, --help help for docker 435 --max-read-ahead SizeSuffix The number of bytes that can be prefetched for sequential reads (not supported on Windows) (default 128Ki) 436 --mount-case-insensitive Tristate Tell the OS the mount is case insensitive (true) or sensitive (false) regardless of the backend (auto) (default unset) 437 --network-mode Mount as remote network drive, instead of fixed disk drive (supported on Windows only) 438 --no-checksum Don't compare checksums on up/download 439 --no-modtime Don't read/write the modification time (can speed things up) 440 --no-seek Don't allow seeking in files 441 --no-spec Do not write spec file 442 --noappledouble Ignore Apple Double (._) and .DS_Store files (supported on OSX only) (default true) 443 --noapplexattr Ignore all "com.apple.*" extended attributes (supported on OSX only) 444 -o, --option stringArray Option for libfuse/WinFsp (repeat if required) 445 --poll-interval Duration Time to wait between polling for changes, must be smaller than dir-cache-time and only on supported remotes (set 0 to disable) (default 1m0s) 446 --read-only Only allow read-only access 447 --socket-addr string Address <host:port> or absolute path (default: /run/docker/plugins/rclone.sock) 448 --socket-gid int GID for unix socket (default: current process GID) (default 1000) 449 --uid uint32 Override the uid field set by the filesystem (not supported on Windows) (default 1000) 450 --umask int Override the permission bits set by the filesystem (not supported on Windows) (default 2) 451 --vfs-block-norm-dupes If duplicate filenames exist in the same directory (after normalization), log an error and hide the duplicates (may have a performance cost) 452 --vfs-cache-max-age Duration Max time since last access of objects in the cache (default 1h0m0s) 453 --vfs-cache-max-size SizeSuffix Max total size of objects in the cache (default off) 454 --vfs-cache-min-free-space SizeSuffix Target minimum free space on the disk containing the cache (default off) 455 --vfs-cache-mode CacheMode Cache mode off|minimal|writes|full (default off) 456 --vfs-cache-poll-interval Duration Interval to poll the cache for stale objects (default 1m0s) 457 --vfs-case-insensitive If a file name not found, find a case insensitive match 458 --vfs-disk-space-total-size SizeSuffix Specify the total space of disk (default off) 459 --vfs-fast-fingerprint Use fast (less accurate) fingerprints for change detection 460 --vfs-read-ahead SizeSuffix Extra read ahead over --buffer-size when using cache-mode full 461 --vfs-read-chunk-size SizeSuffix Read the source objects in chunks (default 128Mi) 462 --vfs-read-chunk-size-limit SizeSuffix If greater than --vfs-read-chunk-size, double the chunk size after each chunk read, until the limit is reached ('off' is unlimited) (default off) 463 --vfs-read-wait Duration Time to wait for in-sequence read before seeking (default 20ms) 464 --vfs-refresh Refreshes the directory cache recursively in the background on start 465 --vfs-used-is-size rclone size Use the rclone size algorithm for Used size 466 --vfs-write-back Duration Time to writeback files after last use when using cache (default 5s) 467 --vfs-write-wait Duration Time to wait for in-sequence write before giving error (default 1s) 468 --volname string Set the volume name (supported on Windows and OSX only) 469 --write-back-cache Makes kernel buffer writes before sending them to rclone (without this, writethrough caching is used) (not supported on Windows) 470 ``` 471 472 473 ## Filter Options 474 475 Flags for filtering directory listings. 476 477 ``` 478 --delete-excluded Delete files on dest excluded from sync 479 --exclude stringArray Exclude files matching pattern 480 --exclude-from stringArray Read file exclude patterns from file (use - to read from stdin) 481 --exclude-if-present stringArray Exclude directories if filename is present 482 --files-from stringArray Read list of source-file names from file (use - to read from stdin) 483 --files-from-raw stringArray Read list of source-file names from file without any processing of lines (use - to read from stdin) 484 -f, --filter stringArray Add a file filtering rule 485 --filter-from stringArray Read file filtering patterns from a file (use - to read from stdin) 486 --ignore-case Ignore case in filters (case insensitive) 487 --include stringArray Include files matching pattern 488 --include-from stringArray Read file include patterns from file (use - to read from stdin) 489 --max-age Duration Only transfer files younger than this in s or suffix ms|s|m|h|d|w|M|y (default off) 490 --max-depth int If set limits the recursion depth to this (default -1) 491 --max-size SizeSuffix Only transfer files smaller than this in KiB or suffix B|K|M|G|T|P (default off) 492 --metadata-exclude stringArray Exclude metadatas matching pattern 493 --metadata-exclude-from stringArray Read metadata exclude patterns from file (use - to read from stdin) 494 --metadata-filter stringArray Add a metadata filtering rule 495 --metadata-filter-from stringArray Read metadata filtering patterns from a file (use - to read from stdin) 496 --metadata-include stringArray Include metadatas matching pattern 497 --metadata-include-from stringArray Read metadata include patterns from file (use - to read from stdin) 498 --min-age Duration Only transfer files older than this in s or suffix ms|s|m|h|d|w|M|y (default off) 499 --min-size SizeSuffix Only transfer files bigger than this in KiB or suffix B|K|M|G|T|P (default off) 500 ``` 501 502 See the [global flags page](/flags/) for global options not listed here. 503 504 # SEE ALSO 505 506 * [rclone serve](/commands/rclone_serve/) - Serve a remote over a protocol. 507