How to Run OneDrive in Docker on a RAID‑Backed Home Server

Self‑hosting a home server is awesome… until you realize your important documents and photos still live only in the cloud. In this guide we’ll walk through how to run the Linux OneDrive client in Docker, keep all synced data on your RAID array, and keep the container itself neatly organized alongside your other stacks.

We’ll also cover what to expect during the first sync (spoiler: if your OneDrive is big, you might be waiting a while ⏳) and how to re‑authenticate later if needed.


1. What We’re Going to Build 🧩

By the end of this guide you’ll have:

  • A Docker container running the open‑source OneDrive client for Linux.
  • OneDrive data stored on a RAID‑backed filesystem, e.g. /srv/dev-disk-by-uuid-.../onedrive/data.
  • OneDrive configuration and tokens stored persistently in /srv/dev-disk-by-uuid-.../onedrive/conf.
  • A docker‑compose stack so the OneDrive service starts automatically with the server.

We’ll assume:

  • Docker is already installed and running on your server (e.g. OpenMediaVault or similar).
  • You have a RAID volume mounted under something like:/srv/dev-disk-by-uuid-801ed916-d6c3-43fe-9beb-6cb6c6101a4a(You’ll replace this with your own path.)

2. Identify the User and Group IDs 👤

The OneDrive container will create and modify files on your RAID array. To avoid permission headaches, map it to the same user and group that should “own” those files.

On the server, run:

id youruser

Replace youruser with the account that should own the synced data.

What you should see ✅

Something like:

uid=1000(youruser) gid=100(users) groups=100(users),27(somegroup),...

Take note of:

  • uid=1000 → this will become ONEDRIVE_UID
  • gid=100 → this will become ONEDRIVE_GID

If something goes wrong ⚠️

  • If you see no such user, double‑check the username or pick another user that does exist.

3. Prepare RAID Folders for OneDrive 📁

We’ll keep OneDrive’s config and data on the RAID volume.

3.1. Pick your RAID base path

Example (adjust to your setup):

RAID_BASE="/srv/dev-disk-by-uuid-801ed916-d6c3-43fe-9beb-6cb6c6101a4a"

3.2. Create OneDrive directories

sudo mkdir -p \
  "$RAID_BASE"/onedrive/conf \
  "$RAID_BASE"/onedrive/data

Verify:

ls -ld "$RAID_BASE"/onedrive/*

You should see two directories: conf and data.

3.3. Confirm this is really on RAID

df -h "$RAID_BASE"

You should see a Filesystem such as md0 or whatever represents your RAID array. It should not be tmpfs, overlay, or anything obviously non‑RAID.

If you get No such file or directory, then:

  • The RAID disk may not be mounted yet.
  • The UUID or path might be incorrect.

Fix the mount or correct the path before continuing.


4. Create a Folder for the Docker Stack 🧱

To keep things consistent with other services, we’ll create a dedicated folder for the OneDrive stack.

sudo mkdir -p /srv/docker/onedrive
ls -ld /srv/docker/onedrive

You should see a directory with normal permissions and no errors.


5. First‑Time Authorization (Interactive OAuth) 🔐

The OneDrive client uses OAuth, which means the very first launch must be interactive: you’ll open a URL in your browser, log into your Microsoft account, and paste the resulting URL back into the container.

We’ll do this using a temporary container that writes the config and token into /onedrive/conf on the RAID volume. Later we’ll switch to a persistent docker‑compose service.

5.1. Run the temporary “setup” container

Replace RAID_BASE, ONEDRIVE_UID, and ONEDRIVE_GID with your actual values.

sudo docker run -it --name onedrive-setup \
  -v /srv/dev-disk-by-uuid-801ed916-d6c3-43fe-9beb-6cb6c6101a4a/onedrive/conf:/onedrive/conf \
  -v /srv/dev-disk-by-uuid-801ed916-d6c3-43fe-9beb-6cb6c6101a4a/onedrive/data:/onedrive/data \
  -e ONEDRIVE_UID=1000 \
  -e ONEDRIVE_GID=100 \
  driveone/onedrive:latest

5.2. What you should see on first run ✅

  • If no config exists yet, the client will create one and show messages similar to:Config file not found, creating a default config file. Config file successfully saved.
  • Then it should print an authorization URL, for example:Open this URL in your browser to authorise the application: https://login.microsoftonline.com/... Enter the response URL:

5.3. Authorize in your browser 🌐

  1. Copy the long https://login.microsoftonline.com/... URL from the terminal.
  2. Paste it into your browser (on your laptop/desktop).
  3. Log in with the Microsoft account whose OneDrive you want to sync.
  4. Accept the requested permissions.
  5. After a successful login, you’ll be redirected to another URL (often a blank page). Copy the entire URL from the browser’s address bar.
  6. Paste that URL into the terminal at the Enter the response URL: prompt and press Enter.

5.4. What to expect after pasting the response URL ✅

You should see output along the lines of:

Application has been successfully authorised, however no additional client configuration was specified.

After that, the client may immediately start the initial sync. This is where you need to be patient.

⏳ Important: The first sync can take a long time

If your OneDrive already contains a lot of files (photos, backups, large folders, etc.), the initial sync can take a long time:

  • It needs to fetch the full directory tree and metadata.
  • Then it starts downloading files into /onedrive/data.

In the terminal, you’ll see a stream of messages about scanning and downloading files. It’s perfectly normal if this takes many minutes or even hours, depending on your connection and data size.

If you don’t want to wait for the full sync during this first interactive run, you can interrupt with Ctrl+C once the app is authorized and the config/token have been created. We’ll restart syncing later via the permanent docker‑compose service.

5.5. Validate that config and token were created

On the host, check the conf folder:

ls -l /srv/dev-disk-by-uuid-801ed916-d6c3-43fe-9beb-6cb6c6101a4a/onedrive/conf

You should see at least a config file and one or more token‑related files.

If the directory is still empty:

  • The container might not have been able to write there (permission issue).
  • You might have aborted before completing the authorization.

Check the container logs:

sudo docker logs onedrive-setup

Look for errors like Permission denied or failures to save the config.

5.6. Remove the temporary container 🧹

Once authorization is complete and the config is present on disk, remove the setup container:

sudo docker stop onedrive-setup  # if it is still running
sudo docker rm onedrive-setup

The configuration and tokens remain safe in the conf directory on your RAID volume.


6. Create a Persistent docker‑compose Service 🔄

Now that authentication is done and the config is on disk, it’s time to create a proper stack that will run OneDrive continuously.

6.1. Create the docker-compose.yml file

Create /srv/docker/onedrive/docker-compose.yml with the following content:

version: "3.8"

services:
  onedrive:
    image: driveone/onedrive:latest
    container_name: onedrive
    restart: unless-stopped
    stdin_open: true   # allow interactive exec if needed
    tty: true          # required for docker exec -it
    environment:
      - ONEDRIVE_UID=1000      # replace with your uid
      - ONEDRIVE_GID=100       # replace with your gid
      # - ONEDRIVE_DOWNLOADONLY=1  # optional: download-only mode
      # - ONEDRIVE_CLEANUPLOCAL=1  # optional: remove local files not present in OneDrive (dangerous!)
      # - ONEDRIVE_VERBOSE=1       # optional: enable verbose logging
    volumes:
      - /srv/dev-disk-by-uuid-801ed916-d6c3-43fe-9beb-6cb6c6101a4a/onedrive/conf:/onedrive/conf
      - /srv/dev-disk-by-uuid-801ed916-d6c3-43fe-9beb-6cb6c6101a4a/onedrive/data:/onedrive/data

Double‑check:

  • image is driveone/onedrive:latest.
  • conf and data volumes point to your actual RAID paths.
  • ONEDRIVE_UID and ONEDRIVE_GID match the values from the id command.

6.2. Start the stack

From the directory containing the compose file:

cd /srv/docker/onedrive
sudo docker compose up -d
# or, if your system still uses docker-compose (hyphen version):
# sudo docker-compose up -d

You should see the usual Creating onedrive ... done or Starting onedrive ... done output with no errors.

Verify that the container is running:

sudo docker ps | grep onedrive

You should see an entry for onedrive with a status like Up 20 seconds.

If the container exits immediately, inspect the logs:

sudo docker logs onedrive

Common issues include missing config, wrong paths, or permission errors.


7. Checking That Sync Is Actually Working 🔍

7.1. Watch the logs

Follow the container logs in real time:

sudo docker logs -f onedrive

You should see messages like:

Initializing the OneDrive API ...
Syncing changes from OneDrive ...

During the initial sync, expect a lot of output as files and directories are scanned and downloaded. Again, be patient – a large OneDrive library will take time to sync. ⌛

Once it has caught up, you’ll see messages such as:

OneDrive sync completed.
Monitor directory: /onedrive/data

This means the client is now watching the local folder for changes and keeping it in sync with the cloud.

7.2. Inspect the data on disk

On the host, list the synced data directory:

ls -R /srv/dev-disk-by-uuid-801ed916-d6c3-43fe-9beb-6cb6c6101a4a/onedrive/data | head

You should start to see your OneDrive folder structure appear.

If nothing appears after a while:

  • Re‑check logs for repeated errors.
  • Make sure there is actually data up in OneDrive.
  • Confirm you didn’t accidentally configure upload‑only mode.

8. Handling Permissions Issues 🛡️

If the client can’t write to your RAID directory, you’ll see errors like:

ERROR: Failed to create directory ... Permission denied

To fix this:

  1. Check ownership of the onedrive directories:ls -ld /srv/dev-disk-by-uuid-801ed916-d6c3-43fe-9beb-6cb6c6101a4a/onedrive/*
  2. If necessary, change ownership to your chosen user and group:sudo chown -R youruser:users /srv/dev-disk-by-uuid-801ed916-d6c3-43fe-9beb-6cb6c6101a4a/onedrive
  3. Restart the container:sudo docker compose restart

After that, watch the logs again to confirm the client can now create directories and write files.


9. Re‑Authenticating Later (Reauth) 🔄

Sometimes you may need to re‑authorize the client:

  • You changed your Microsoft account password.
  • Tokens expired and can’t be refreshed.
  • You want to connect a different OneDrive account.

You don’t need a new container for this. Just run:

sudo docker exec -it onedrive onedrive --reauth

This will print a new authorization URL, and the process is exactly the same as the first time:

  1. Copy URL from terminal → open in browser.
  2. Log in and grant access.
  3. Copy the final URL from the browser and paste it into the terminal.

Once it says the application is authorized, the container continues syncing with the new token.


10. Optional: Tuning What Gets Synced 🎛️

Once the basic sync works, you might want more control:

  • Edit the config file in /onedrive/conf to adjust advanced options (like sync_dir, upload/download modes, etc.).
  • Create a sync_list file in the same directory to restrict sync to specific folders rather than the entire OneDrive.

For example, you might only want:

  • Documents
  • Photos

and ignore everything else. The sync_list mechanism lets you whitelist only the paths you care about.

(Always restart the container after changing config files so the client reloads them.)


11. Will OneDrive and Other Services Mix Data? 🤔

If you’re also running services like Nextcloud on the same RAID array, you might worry they’ll interfere with each other.

The solution is simple:

  • Use separate directories for each service:
    • OneDrive data: /.../onedrive/data
    • Nextcloud data: /.../nextcloud/data

As long as you don’t point two different services at the same host directory, they won’t mix or corrupt each other’s files.

If you ever want Nextcloud to read files synced by OneDrive, you can expose /.../onedrive/data as an external storage in Nextcloud instead of merging their data directories.


12. Summary 🧾

You now have a robust setup where:

  • The OneDrive Linux client runs inside Docker.
  • All data and configuration live on a RAID‑backed filesystem.
  • The service is managed via docker‑compose, just like your other containers.
  • The first sync might be long if your OneDrive is large, but after that it quietly keeps things up to date in the background.

This approach gives you the best of both worlds: the reliability and redundancy of your local RAID storage, and the convenience and off‑site backup of OneDrive. 🚀☁️

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.