2018-12-04 01:59:03 +01:00
# onedrive docker image
Thats right folks onedrive is now dockerized ;)
This container offers simple monitoring-mode service for 'Free Client for OneDrive on Linux'.
## Usage instructions
2019-01-22 02:31:57 +01:00
2019-01-25 15:03:40 +01:00
### 0. Install docker under your own platform's instructions
2019-01-22 02:31:57 +01:00
2019-01-22 02:34:44 +01:00
### 1. Pull the image
2019-01-22 02:31:57 +01:00
2019-01-06 17:02:58 +01:00
```bash
2018-12-04 01:59:03 +01:00
docker pull driveone/onedrive
```
2019-01-23 02:20:52 +01:00
2019-01-06 00:14:49 +01:00
**NOTE:** SELinux context needs to be configured or disabled for Docker, to be able to write to OneDrive host directory.
2018-12-04 01:59:03 +01:00
2019-01-22 02:34:44 +01:00
### 2. Prepare required stuff
2019-01-22 02:31:57 +01:00
2019-01-22 09:37:47 +01:00
Onedrive needs two volumes. One of them is the config volume.
If you dont't need an extra config file, You can create a docker volume:
2019-01-23 02:20:52 +01:00
2019-01-06 00:14:49 +01:00
```bash
2019-01-25 15:03:40 +01:00
docker volume create onedrive_conf
2019-01-22 02:31:57 +01:00
```
2018-12-04 01:59:03 +01:00
2019-01-22 04:40:19 +01:00
This will create a docker volume labeled 'onedrive_conf', which we will use it later.
2019-01-22 02:31:57 +01:00
2019-01-22 09:37:47 +01:00
The second one is your data folder that needs to sync with. Keep in mind that:
2019-01-23 02:20:52 +01:00
- The owner of the folder must not be root
- The owner have permission to its parent directory
(because onedrive will try to setup a monitor for the sync folder).
2019-01-22 02:31:57 +01:00
2019-01-22 02:34:44 +01:00
### 3. First run
2019-01-22 02:31:57 +01:00
2019-01-22 09:37:47 +01:00
Onedrive also needs to be authorized with your account.
This is done by running docker in interactive mode.
2019-01-22 02:31:57 +01:00
**make sure to change onedriveDir to your own.**
2019-01-23 02:20:52 +01:00
2019-01-22 02:31:57 +01:00
```bash
onedriveDir="${HOME}/OneDrive"
docker run -it --restart unless-stopped --name onedrive -v onedrive_conf:/onedrive/conf -v "${onedriveDir}:/onedrive/data" driveone/onedrive
2018-12-04 01:59:03 +01:00
```
2019-01-22 02:31:57 +01:00
2019-01-23 02:20:52 +01:00
- You will be asked to open a specific link using your web browser
- login into your Microsoft Account and give the application the permission
- After giving the permission, you will be redirected to a blank page.
- Copy the URI of the blank page into the application.
2019-01-22 02:31:57 +01:00
If your onedrive is working as expected, you can detach from the container with Ctrl+p, Ctrl+q.
2019-01-22 04:40:19 +01:00
### 4. Status, stop, and restart
2019-01-22 02:31:57 +01:00
Check if monitor service is running
2019-01-23 02:20:52 +01:00
2019-01-06 17:02:58 +01:00
```bash
2018-12-04 01:59:03 +01:00
docker ps -f name=onedrive
```
2019-01-22 02:31:57 +01:00
Show monitor run logs
2019-01-23 02:20:52 +01:00
2019-01-06 17:02:58 +01:00
```bash
2018-12-04 01:59:03 +01:00
docker logs onedrive
```
2019-01-22 02:31:57 +01:00
Stop running monitor
2019-01-23 02:20:52 +01:00
2019-01-06 17:02:58 +01:00
```bash
2018-12-04 01:59:03 +01:00
docker stop onedrive
```
2019-01-22 02:31:57 +01:00
Resume monitor
2019-01-23 02:20:52 +01:00
2019-01-06 17:02:58 +01:00
```bash
2018-12-04 01:59:03 +01:00
docker start onedrive
```
2019-01-22 02:31:57 +01:00
Unregister onedrive monitor
2019-01-23 02:20:52 +01:00
2019-01-06 17:02:58 +01:00
```bash
2018-12-04 01:59:03 +01:00
docker rm -f onedrive
```
2019-01-22 02:31:57 +01:00
2019-01-22 04:40:19 +01:00
### 5. Edit the config
2019-01-22 02:31:57 +01:00
2019-01-22 09:37:47 +01:00
Onedrive should run in default configuration, but however you can change your configuration.
2019-01-23 02:20:52 +01:00
First download the default config from [here ](https://raw.githubusercontent.com/abraunegg/onedrive/master/config )
2019-01-23 05:46:41 +01:00
Then put it into your onedrive_conf volume path, which can be found with:
```bash
docker volume inspect onedrive_conf
```
2019-01-22 09:37:47 +01:00
Or you can map your own config folder to config volume (copy stuffs from docker volume first)
The detailed document for the config can be found here: [additional-configuration ](https://github.com/abraunegg/onedrive#additional-configuration )
2019-01-22 02:31:57 +01:00
## Run or update with one script
2019-01-23 02:20:52 +01:00
2019-01-22 02:31:57 +01:00
If you are experienced with docker and onedrive, you can use the following script:
2019-01-23 02:20:52 +01:00
2019-01-22 02:31:57 +01:00
```bash
# Update onedriveDir with correct existing OneDrive directory path
onedriveDir="${HOME}/OneDrive"
firstRun='-d'
docker pull driveone/onedrive
docker inspect onedrive_conf > /dev/null || { docker volume create onedrive_conf; firstRun='-it'; }
docker inspect onedrive > /dev/null & & docker rm -f onedrive
docker run $firstRun --restart unless-stopped --name onedrive -v onedrive_conf:/onedrive/conf -v "${onedriveDir}:/onedrive/data" driveone/onedrive
```
2019-09-09 05:44:07 +02:00
## Environment Variables
| Variable | Purpose | Sample Value |
| ---------------- | --------------------------------------------------- |:-------------:|
| < B > ONEDRIVE_UID< / B > | UserID (UID) to run as | 1000 |
| < B > ONEDRIVE_GID< / B > | GroupID (GID) to run as | 1000 |
| < B > ONEDRIVE_VERBOSE< / B > | Controls "verbose" switch on onedrive sync. Default (i.e. not set or non-zero value) behaviour is to continue to be verbose as before | 0 |
2018-12-04 01:59:03 +01:00
## Build instructions
2019-01-24 18:18:48 +01:00
You can also build your own image instead of pulling the one from dockerhub:
2019-01-06 00:14:49 +01:00
```bash
2018-12-04 01:59:03 +01:00
git clone https://github.com/abraunegg/onedrive
2019-01-25 15:03:40 +01:00
cd onedrive
2019-06-11 10:40:05 +02:00
docker build . -t local-onedrive -f contrib/docker/Dockerfile
2018-12-04 01:59:03 +01:00
```
2019-02-16 20:13:19 +01:00
There are alternate, smaller images available by building
Dockerfile-stretch or Dockerfile-alpine. These [multi-stage builder
pattern](https://docs.docker.com/develop/develop-images/multistage-build/)
Dockerfiles require Docker version at least 17.05.
``` bash
2019-06-11 10:40:05 +02:00
docker build . -t local-ondrive-stretch -f contrib/docker/Dockerfile-stretch
2019-02-16 20:13:19 +01:00
```
or
``` bash
2019-06-11 10:40:05 +02:00
docker build . -t local-ondrive-alpine -f contrib/docker/Dockerfile-alpine
2019-02-16 20:13:19 +01:00
```