[GUIDE] Set up the OneDrive Client for Linux (abraunegg) as Docker container


Recommended Posts

I am a new user of Unraid and Docker and was looking for an alternative to Synology Cloud Sync, which I used to keep all my family's Onedrive files as harcopy on my previous NAS (multiple accounts). I was therefor not looking for an app like Duplicati/Duplicay to spread my files even further over the cloud, but to get my files back from the cloud and keep them synchronized. For this purpose I decided to run the Onedrive Client for Linux in a separate docker container for different Onedrive accounts on my Unraid install, which seems to work quite well. Below my beginners guide for how to set this up with docker compose following this guide

Requirements:

  • Docker compose installed
  • Dynamix File Manager installed (helpful)


Step 1:
In the Unraid WebUI open the terminal and type ‘id username’ for every user with onedrive account you want to install a Onedrive container for and write down the UID and GID for these users.

 

Step 2:
Add a share called ‘onedrive’ (or choose your own name). Optionally enable cache, select preferred disk(s) and decide if you want to export the share.

 

Step 3:
If you are planning to use multiple containers/accounts, create subfolders for every user as well in the just created onedrive folder (/onedrive/userA, /onedrive/userB, etc.). Do this before running the container later on.

 

Step 4:
Create a ‘onedrive’ folder under /mnt/user/appdata/ and again create subfolders (userA, userB etc.) for different users

 

Step 5:
Go to the Docker tab, scroll down to Compose and press ‘Add new stack’

Step 6:
Type a project name (for example Onedrive-userA) and press ‘OK’ and again ‘OK’ after success

Step 7:
Click on the cog-wheel of the new created stack and press ‘Edit stack’ followed by ‘Compose file’

 

Step 8:
Past in the composer file below:

version: "3.7"
services:
    onedrive:
        image: driveone/onedrive:latest
        container_name: Onedrive-userA
        stdin_open: true # docker run -i
        tty: true        # docker run -t
        restart: unless-stopped
        environment:
            - ONEDRIVE_UID=1001
            - ONEDRIVE_GID=100
        volumes: 
            - /mnt/user/appdata/onedrive/userA:/onedrive/conf/
            - /mnt/user/onedrive/userA:/onedrive/data

 

Step 9:
Before saving, make the following changes to the composer file:

·       Change the container name in a name of your liking, for example Onedrive_UserA, Onedrive_UserB.

·       Change the UID and GID to the correct values for the user, as found in step 1

·       Under volumes change the path left from the colon to the correct config and data folder (so ‘/mnt/user/appdata/onedrive/userA’ and ‘/mnt/user/onedrive/userA’ if the example above has been followed. Don't touch the values right from the colon.

·       Optionally, if you created your custom network for docker containers, you can add the network settings below and change 'nameofyournetwork' to the name of your network. Otherwise a new network (container_name_default) is created. Example:

version: "3.7"
services:
    onedrive:
        image: driveone/onedrive:latest
        container_name: Onedrive-userA
        stdin_open: true # docker run -i
        tty: true        # docker run -t
        restart: unless-stopped
        environment:
            - ONEDRIVE_UID=1001
            - ONEDRIVE_GID=100
        volumes: 
            - /mnt/user/appdata/onedrive/userA:/onedrive/conf/
            - /mnt/user/onedrive/userA:/onedrive/data
        networks:
            - proxy
networks:
  proxy:
    external: true
    name: nameofyournetwork   

 

Step 10:
Press ‘save changes’

 

Step 11 (optional):
If you want to add an icon to your docker container (otherwise you’ll see a questionmark), press the cog-wheel again, select ‘edit stack’ and select UI labels. On the internet find a link to the icon of your choosing (for example from Onedrive’s wiki) and past the link in this field. This can be done later on as well (by updating the stack). Press ‘OK’ when done.

 

Step 12:
Press ‘Compose up’ and press ‘Done’ when it is done.

 

A new container is now created and running, but the Onedrive Client still needs to be connected to your Microsoft account with the following steps:

Step 13:
Stop the new container

 

Step 14:

In the right upper corner of the docker page, switch over from ‘Basic view’ to ‘Advanced view’. Now you can see the Container ID for your newly made container (for example 72409c107bd0). Copy this number.

 

Step 15:
Open the Unraid terminal and enter:

docker start your_container_id --interactive

Use right mouse and paste to paste your container ID in the terminal.


Step 16:
After entering the command and pressing enter, the container starts in an interactive mode and a link to Microsoft is shown in the terminal. You open this link by clicking on it and log in with the Microsoft credentials of the onedrive account you want to add. If successful, a blank page is shown. Copy the full address of this page and past it (right mouse and paste) in the terminal as the response URL and press enter. If the link is accepted, the client immediately starts downloading your files.

 

Step 17:
You can close the terminal, restart the container and everything should be working from now on.

 

Step 18:

Repeat step 5-17 for every account you want to add. For some reason you need to select a different Icon URL for every new container you want to add.

Edited by BVersluis
Link to comment
  • 2 weeks later...
  • 3 weeks later...
On 1/25/2023 at 4:10 AM, Guo Jiacheng said:

How can I change the new created file permission to 755? Right now, to share between users, I have repeatedly change new synced file permission to 755. The default permission is 500 ?

Yes, default is 500. Every Unraid user with his/her own UID has only access to his/her files Onedrive by default. If one Unraid user has multiple Onedrive accounts, you could use the same UID and have access to all files, but by default only the owner of the files (container) has access. To my knowledge - and my Docker knowledge is very limited - there is no easy way to change this in docker (in combination with mounted volumes). Depending on your needs, one 'solution' could be to create an Unraid user (UID) for all Onedrive accounts you want to share files between and use this account to access your files. Perhaps this might be of help.

Edited by BVersluis
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.