Run Dropbox client in a Docker container

Posted by Valentin Heidelberger on Wednesday, March 7, 2018 Tags: Docker Technology Linux Shell   6 minute read


The official Dropbox client seems to be quite a mess on some Linux distributions. There are official packages for Ubuntu/Debian and Fedora/RedHat, which seem to be pretty stable, but at least in my distribution (which builds it from source) it is unusable. Considering the plethora of distros, that are out there, it is a good idea to not waste much time trying to get it to work on your particular distro, but to simply use a Docker container.


Implementing this is actually incredibly simple. Just add the following two shell aliases to your .bashrc, .zshrc or whatever:

   alias dropbox="docker exec -it dropbox dropbox"
   alias dropbox-start="docker run -d --restart=always --name=dropbox -v /home/val/Dropbox:/dbox/Dropbox -v /home/val/.dropbox:/dbox/.dropbox -e DBOX_UID=1000 -e DBOX_GID=100 janeczku/dropbox"

The alias dropbox-start pulls the docker image janeczku/dropbox from Dockerhub and runs it with restart set to always. This makes sure, that the container is immediately restarted, if it crashes and also starts it on system boot. Also the command mounts the folders /home/val/Dropbox and /home/val/.dropbox at the mountpoints /dbox/Dropbox and /dbox/.dropbox inside the container and gives the container two variables containing the UID and GID to use for read/write operations.

Don’t forget to replace the folder paths with your desired paths and the variables DBOX_UID and DBOX_GID with your uid/gid; otherwise Dropbox might have a permission problem. Don’t give it the UID “0”, because that is root and you just don’t wan’t something to run with root privileges, if it doesn’t need to.

Make sure, that the folders /home/user/Dropbox and /home/user/.dropbox do not exist before you execute dropbox-start the first time. Dropbox insists on creating these folders itself and will simply crash over and over again if it can’t. I spent quite some time debugging until I found that out actually…

dropbox-start should print a container ID to your screen, if it was successful. You can also use “docker ps” to check, if and how long the container’s running:

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
91eee27158bb        janeczku/dropbox    "/root/run"         3 days ago          Up 4 hours          17500/tcp           dropbox

Once the container is up and running, you need to check it’s logs to link the client to your Dropbox account. Dropbox keeps printing a link to the logs until you connect it to a account:

$ docker logs --follow 91eee27158bb
Checking for latest Dropbox version...
Latest   : 44.4.58
Installed: 11.4.21
Downloading Dropbox v44.4.58...
######################################################################## 100.0%
Installing new version...
Dropbox updated to v44.4.58
Starting dropboxd (44.4.58)...
dropbox: locating interpreter
!! dropbox: failed to create log file (Permission denied)!
dropbox: initializing
dropbox: initializing python 2.7.11
dropbox: setting program path '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/dropbox'
dropbox: setting home path '/opt/dropbox/dropbox-lnx.x86_64-44.4.58'
dropbox: setting python path '/opt/dropbox/dropbox-lnx.x86_64-44.4.58:/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
dropbox: python initialized
dropbox: running dropbox
dropbox: setting args
dropbox: applying overrides
dropbox: running main script
dropbox: load fq extension '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
dropbox: load fq extension '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
dropbox: load fq extension '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
dropbox: load fq extension '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
dropbox: load fq extension '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
dropbox: load fq extension '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
dropbox: load fq extension '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
dropbox: load fq extension '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
dropbox: load fq extension '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
dropbox: load fq extension '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
dropbox: load fq extension '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
dropbox: load fq extension '/opt/dropbox/dropbox-lnx.x86_64-44.4.58/'
This computer isn't linked to any Dropbox account...
Please visit to link this device.
This computer isn't linked to any Dropbox account...

Of course the nonce will be different in your logs. Open the link in your web browser to authenticate and connect. Once the client has been successfully linked to your account a message will appear in the logs and the client will start syncing:

Please visit to link this device.
This computer is now linked to Dropbox. Welcome Valentin

The alias dropbox simply executes the “dropbox” command inside the container. With the various subcommands of “dropbox” you can check lots of things. E.g. if it’s currently synchronizing something:

$ dropbox status
Up to date

Calling the “dropbox” alias without a subcommand will output a list of available subcommands:

$ dropbox
Dropbox command-line interface


Note: use dropbox help <command> to view usage for a specific command.

 status       get current status of the dropboxd
 throttle     set bandwidth limits for Dropbox
 help         provide help
 puburl       get public url of a file in your dropbox's public folder
 stop         stop dropboxd
 running      return whether dropbox is running
 start        start dropboxd
 filestatus   get current sync status of one or more files
 ls           list directory contents with current sync status
 autostart    automatically start dropbox at login
 exclude      ignores/excludes a directory from syncing
 lansync      enables or disables LAN sync
 sharelink    get a shared link for a file in your dropbox
 proxy        set proxy settings for Dropbox


Containerizing apps is a very nice thing in general, because it makes the stuff inside the container basically independent from what’s going on outside (system updates, new/old versions of libraries, etc.). However, you should always check what’s going on in the Docker images, before giving it’s container access to your private data. Especially, if you don’t know the author(s). The source for the docker image used above is available on GitHub and built automatically from there, so you can actually check what’s going on. I know it’s a bit ironic to talk about privacy in an article about Dropbox but remember: everyone can upload their stuff to Dockerhub and theoretically hide something inside.

So, embrace simplicity, but keep your eyes peeled.