├── dropbox ├── LICENSE ├── Dockerfile ├── README.md └── run /dropbox: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ $# -gt 0 ]; then 3 | su dropbox -s /bin/bash -c "dropbox-cli $(printf "%q " "$@")" 4 | else 5 | su dropbox -s /bin/bash -c dropbox-cli 6 | fi -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (C) 2015-2016 Jan Broer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | MAINTAINER Jan Broer 3 | ENV DEBIAN_FRONTEND noninteractive 4 | 5 | # Following 'How do I add or remove Dropbox from my Linux repository?' - https://www.dropbox.com/en/help/246 6 | RUN echo 'deb http://linux.dropbox.com/debian jessie main' > /etc/apt/sources.list.d/dropbox.list \ 7 | && apt-key adv --keyserver pgp.mit.edu --recv-keys 1C61A2656FB57B7E4DE0F4C1FC918B335044912E \ 8 | && apt-get -qqy update \ 9 | # Note 'ca-certificates' dependency is required for 'dropbox start -i' to succeed 10 | && apt-get -qqy install ca-certificates curl python-gpgme dropbox \ 11 | # Perform image clean up. 12 | && apt-get -qqy autoclean \ 13 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ 14 | # Create service account and set permissions. 15 | && groupadd dropbox \ 16 | && useradd -m -d /dbox -c "Dropbox Daemon Account" -s /usr/sbin/nologin -g dropbox dropbox 17 | 18 | # Dropbox is weird: it insists on downloading its binaries itself via 'dropbox 19 | # start -i'. So we switch to 'dropbox' user temporarily and let it do its thing. 20 | USER dropbox 21 | RUN mkdir -p /dbox/.dropbox /dbox/.dropbox-dist /dbox/Dropbox /dbox/base \ 22 | && echo y | dropbox start -i 23 | 24 | # Switch back to root, since the run script needs root privs to chmod to the user's preferrred UID 25 | USER root 26 | 27 | # Dropbox has the nasty tendency to update itself without asking. In the processs it fills the 28 | # file system over time with rather large files written to /dbox and /tmp. The auto-update routine 29 | # also tries to restart the dockerd process (PID 1) which causes the container to be terminated. 30 | RUN mkdir -p /opt/dropbox \ 31 | # Prevent dropbox to overwrite its binary 32 | && mv /dbox/.dropbox-dist/dropbox-lnx* /opt/dropbox/ \ 33 | && mv /dbox/.dropbox-dist/dropboxd /opt/dropbox/ \ 34 | && mv /dbox/.dropbox-dist/VERSION /opt/dropbox/ \ 35 | && rm -rf /dbox/.dropbox-dist \ 36 | && install -dm0 /dbox/.dropbox-dist \ 37 | # Prevent dropbox to write update files 38 | && chmod u-w /dbox \ 39 | && chmod o-w /tmp \ 40 | && chmod g-w /tmp \ 41 | # Prepare for command line wrapper 42 | && mv /usr/bin/dropbox /usr/bin/dropbox-cli 43 | 44 | # Install init script and dropbox command line wrapper 45 | COPY run /root/ 46 | COPY dropbox /usr/bin/dropbox 47 | 48 | WORKDIR /dbox/Dropbox 49 | EXPOSE 17500 50 | VOLUME ["/dbox/.dropbox", "/dbox/Dropbox"] 51 | ENTRYPOINT ["/root/run"] 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dropbox in Docker 2 | 3 | [![Docker Pulls](https://img.shields.io/docker/pulls/janeczku/dropbox.svg?maxAge=2592000)][hub] 4 | [![License](https://img.shields.io/github/license/janeczku/docker-alpine-kubernetes.svg?maxAge=2592000)]() 5 | 6 | [hub]: https://hub.docker.com/r/janeczku/dropbox/ 7 | 8 | Run Dropbox inside Docker. Fully working with local host folder mount or inter-container linking (via `--volumes-from`). 9 | 10 | This repository provides the [janeczku/dropbox](https://registry.hub.docker.com/u/janeczku/dropbox/) image. 11 | 12 | ## Usage examples 13 | 14 | ### Quickstart 15 | 16 | docker run -d --restart=always --name=dropbox janeczku/dropbox 17 | 18 | ### Dropbox data mounted to local folder on the host 19 | 20 | docker run -d --restart=always --name=dropbox \ 21 | -v /path/to/localfolder:/dbox/Dropbox \ 22 | janeczku/dropbox 23 | 24 | ### Run dropbox with custom user/group id 25 | This fixes file permission errrors that might occur when mounting the Dropbox file folder (`/dbox/Dropbox`) from the host or a Docker container volume. You need to set `DBOX_UID`/`DBOX_GID` to the user id and group id of whoever owns these files on the host or in the other container. 26 | 27 | docker run -d --restart=always --name=dropbox \ 28 | -e DBOX_UID=110 \ 29 | -e DBOX_GID=200 \ 30 | janeczku/dropbox 31 | 32 | ### Enable LAN Sync 33 | 34 | docker run -d --restart=always --name=dropbox \ 35 | --net="host" \ 36 | janeczku/dropbox 37 | 38 | ## Linking to Dropbox account after first start 39 | 40 | Check the logs of the container to get URL to authenticate with your Dropbox account. 41 | 42 | docker logs dropbox 43 | 44 | Copy and paste the URL in a browser and login to your Dropbox account to associate. 45 | 46 | docker logs dropbox 47 | 48 | You should see something like this: 49 | 50 | > "This computer is now linked to Dropbox. Welcome xxxx" 51 | 52 | ## Manage exclusions and check sync status 53 | 54 | docker exec -t -i dropbox dropbox help 55 | 56 | ## ENV variables 57 | 58 | **DBOX_UID** 59 | Default: `1000` 60 | Run Dropbox with a custom user id (matching the owner of the mounted files) 61 | 62 | **DBOX_GID** 63 | Default: `1000` 64 | Run Dropbox with a custom group id (matching the group of the mounted files) 65 | 66 | **$DBOX_SKIP_UPDATE** 67 | Default: `False` 68 | Set this to `True` to skip updating to the latest Dropbox version on container start 69 | 70 | 71 | ## Exposed volumes 72 | 73 | `/dbox/Dropbox` 74 | Dropbox files 75 | 76 | `/dbox/.dropbox` 77 | Dropbox account configuration 78 | -------------------------------------------------------------------------------- /run: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script is a fork of https://github.com/excelsiord/docker-dropbox 3 | 4 | # Set UID/GID if not provided with enviromental variable(s). 5 | if [ -z "$DBOX_UID" ]; then 6 | DBOX_UID=$(cat /etc/passwd | grep dropbox | cut -d: -f3) 7 | echo "DBOX_UID variable not specified, defaulting to dropbox user id ($DBOX_UID)" 8 | fi 9 | 10 | if [ -z "$DBOX_GID" ]; then 11 | DBOX_GID=$(cat /etc/group | grep dropbox | cut -d: -f3) 12 | echo "DBOX_GID variable not specified, defaulting to dropbox user group id ($DBOX_GID)" 13 | fi 14 | 15 | # Look for existing group, if not found create dropbox with specified GID. 16 | FIND_GROUP=$(grep ":$DBOX_GID:" /etc/group) 17 | 18 | if [ -z "$FIND_GROUP" ]; then 19 | usermod -g users dropbox 20 | groupdel dropbox 21 | groupadd -g $DBOX_GID dropbox 22 | fi 23 | 24 | # Set dropbox account's UID. 25 | usermod -u $DBOX_UID -g $DBOX_GID --non-unique dropbox > /dev/null 2>&1 26 | 27 | # Change ownership to dropbox account on all working folders. 28 | chown -R $DBOX_UID:$DBOX_GID /dbox 29 | 30 | # Change permissions on Dropbox folder 31 | chmod 755 /dbox/Dropbox 32 | 33 | # Dropbox did not shutdown properly? Remove files. 34 | [ ! -e "/dbox/.dropbox/command_socket" ] || rm /dbox/.dropbox/command_socket 35 | [ ! -e "/dbox/.dropbox/iface_socket" ] || rm /dbox/.dropbox/iface_socket 36 | [ ! -e "/dbox/.dropbox/unlink.db" ] || rm /dbox/.dropbox/unlink.db 37 | [ ! -e "/dbox/.dropbox/dropbox.pid" ] || rm /dbox/.dropbox/dropbox.pid 38 | 39 | # Update Dropbox to latest version unless DBOX_SKIP_UPDATE is set 40 | if [[ -z "$DBOX_SKIP_UPDATE" ]]; then 41 | echo "Checking for latest Dropbox version..." 42 | sleep 1 43 | # Get download link for latest dropbox version 44 | DL=$(curl -I -s https://www.dropbox.com/download/\?plat\=lnx.x86_64 | grep ocation | awk -F'ocation: ' '{print $2}') 45 | # Strip CRLF 46 | DL=${DL//[$'\t\r\n ']} 47 | # Extract version string 48 | Latest=$(echo $DL | sed 's/.*x86_64-\([0-9]*\.[0-9]*\.[0-9]*\)\.tar\.gz/\1/') 49 | # Get current Version 50 | Current=$(cat /opt/dropbox/VERSION) 51 | echo "Latest :" $Latest 52 | echo "Installed:" $Current 53 | if [ ! -z "${Latest}" ] && [ ! -z "${Current}" ] && [ $Current != $Latest ]; then 54 | echo "Downloading Dropbox v$Latest..." 55 | tmpdir=`mktemp -d` 56 | curl -# -L $DL | tar xzf - -C $tmpdir 57 | echo "Installing new version..." 58 | rm -rf /opt/dropbox/* 59 | mv $tmpdir/.dropbox-dist/* /opt/dropbox/ 60 | rm -rf $tmpdir 61 | echo "Dropbox updated to v$Latest" 62 | else 63 | echo "Dropbox is up-to-date" 64 | fi 65 | fi 66 | 67 | echo "Starting dropboxd ($(cat /opt/dropbox/VERSION))..." 68 | umask 002 69 | exec su dropbox -s /bin/bash -c /opt/dropbox/dropboxd 70 | --------------------------------------------------------------------------------